From cf730d8ce1341ba593144df2e2bc8411238e04c3 Mon Sep 17 00:00:00 2001 From: Kirill Stoimenov Date: Tue, 25 Jan 2022 21:33:55 +0000 Subject: [PATCH] [ASan] Not linking asan_static library for DSO. Without this change DSOs fail to link because of missing asan_report_(load|store)n functions. Reviewed By: kda Differential Revision: https://reviews.llvm.org/D118184 --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 3897f67d1fe6..5711998f9043 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -826,16 +826,16 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes()) StaticRuntimes.push_back("stats_client"); - // Always link the static runtime regardless of DSO or executable. - if (SanArgs.needsAsanRt()) - HelperStaticRuntimes.push_back("asan_static"); - // Collect static runtimes. if (Args.hasArg(options::OPT_shared)) { // Don't link static runtimes into DSOs. return; } + // Always link the static runtime for executable. + if (SanArgs.needsAsanRt()) + HelperStaticRuntimes.push_back("asan_static"); + // Each static runtime that has a DSO counterpart above is excluded below, // but runtimes that exist only as static are not affected by needsSharedRt.