[clang] cf730d8 - [ASan] Not linking asan_static library for DSO.

Kirill Stoimenov via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 25 16:13:35 PST 2022


Author: Kirill Stoimenov
Date: 2022-01-26T00:13:26Z
New Revision: cf730d8ce1341ba593144df2e2bc8411238e04c3

URL: https://github.com/llvm/llvm-project/commit/cf730d8ce1341ba593144df2e2bc8411238e04c3
DIFF: https://github.com/llvm/llvm-project/commit/cf730d8ce1341ba593144df2e2bc8411238e04c3.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3897f67d1fe64..5711998f90434 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.
 


        


More information about the cfe-commits mailing list