Make sure that we put the rest of the sanitizer libraries on the link line

before libstdc++ like we do with ubsan.

llvm-svn: 168918
This commit is contained in:
Eric Christopher 2012-11-29 18:51:05 +00:00
parent e1e835c626
commit 0499778517
2 changed files with 18 additions and 7 deletions

View 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))

View File

@ -11,6 +11,19 @@
// 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 \