forked from OSchip/llvm-project
Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.
It makes no sense to link in sanitizer runtimes in this case: the user probably doesn't want to see any system/toolchain libs in his link if he provides these flags, and the link will most likely fail anyway - as sanitizer runtimes depend on libpthread, libdl, libc etc. Also, see discussion in https://code.google.com/p/address-sanitizer/issues/detail?id=344 llvm-svn: 218541
This commit is contained in:
parent
f572f3b2c0
commit
58ae9ae23a
|
@ -2243,6 +2243,10 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
|
|||
// C runtime, etc). Returns true if sanitizer system deps need to be linked in.
|
||||
static bool addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
|
||||
ArgStringList &CmdArgs) {
|
||||
// Don't link in any sanitizer runtimes if we have no system libraries.
|
||||
if (Args.hasArg(options::OPT_nostdlib) ||
|
||||
Args.hasArg(options::OPT_nodefaultlibs))
|
||||
return false;
|
||||
SmallVector<StringRef, 4> SharedRuntimes, StaticRuntimes,
|
||||
HelperStaticRuntimes;
|
||||
collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
|
||||
|
|
|
@ -301,3 +301,10 @@
|
|||
// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
|
||||
// CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
|
||||
// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
|
||||
|
||||
// RUN: %clang -nostdlib -fsanitize=address %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target x86_64-unknown-linux \
|
||||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-NOSTDLIB %s
|
||||
// CHECK-NOSTDLIB: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-NOSTDLIB-NOT: libclang_rt.asan
|
||||
|
|
Loading…
Reference in New Issue