]> granicus.if.org Git - clang/commitdiff
Make sure that we put the rest of the sanitizer libraries on the link line
authorEric Christopher <echristo@gmail.com>
Thu, 29 Nov 2012 18:51:05 +0000 (18:51 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 29 Nov 2012 18:51:05 +0000 (18:51 +0000)
before libstdc++ like we do with ubsan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168918 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/asan-ld.c

index 4d562d3f8bdc5b0fac848f00c321b54cc195ff23..f9cb5eff53350352a4f88acf2b8c97602f8fe66a 100644 (file)
@@ -5423,9 +5423,13 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
 
   SanitizerArgs Sanitize(D, Args);
 
-  // Call this before we add the C++ ABI library.
+  // Call these before we add the C++ ABI library.
   if (Sanitize.needsUbsanRt())
     addUbsanRTLinux(getToolChain(), Args, CmdArgs);
+  if (Sanitize.needsAsanRt())
+    addAsanRTLinux(getToolChain(), Args, CmdArgs);
+  if (Sanitize.needsTsanRt())
+    addTsanRTLinux(getToolChain(), Args, CmdArgs);
 
   if (D.CCCIsCXX &&
       !Args.hasArg(options::OPT_nostdlib) &&
@@ -5440,12 +5444,6 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-lm");
   }
 
-  // Call this before we add the C run-time.
-  if (Sanitize.needsAsanRt())
-    addAsanRTLinux(getToolChain(), Args, CmdArgs);
-  if (Sanitize.needsTsanRt())
-    addTsanRTLinux(getToolChain(), Args, CmdArgs);
-
   if (!Args.hasArg(options::OPT_nostdlib)) {
     if (!Args.hasArg(options::OPT_nodefaultlibs)) {
       if (Args.hasArg(options::OPT_static))
index ceb195cb91ca95443371ed2857106b8150e47fb0..9d8cbeca0d50e863276b92e4a8cb8339477befb0 100644 (file)
 // CHECK-LINUX: "-lpthread"
 // CHECK-LINUX: "-ldl"
 // CHECK-LINUX: "-export-dynamic"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target i386-unknown-linux -fsanitize=address \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-CXX %s
+//
+// CHECK-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LINUX-CXX-NOT: "-lc"
+// CHECK-LINUX-CXX: libclang_rt.asan-i386.a"
+// CHECK-LINUX-CXX: "-lpthread"
+// CHECK-LINUX-CXX: "-ldl"
+// CHECK-LINUX-CXX: "-export-dynamic"
+// CHECK-LINUX-CXX: stdc++
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target arm-linux-androideabi -fsanitize=address \