[clang] a3b9edf - [ASan] Driver changes to always link-in asan_static library.

Kirill Stoimenov via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 11 07:32:24 PST 2022


Author: Kirill Stoimenov
Date: 2022-01-11T15:31:41Z
New Revision: a3b9edf8b8c3815c1a2c200f9bc00882e1244827

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

LOG: [ASan] Driver changes to always link-in asan_static library.

This enables the changes from D116182.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116670

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/CommonArgs.cpp
    clang/test/Driver/sanitizer-ld.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index f25fe9ba34c4..3897f67d1fe6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,10 @@ 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.

diff  --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c
index d62e19fd4021..ea8c49f2384a 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \


        


More information about the cfe-commits mailing list