Driver: Stop linking to C++ when using sanitizers on Darwin
Sanitizers on Darwin are built as dynamic libraries, not static libraries. Sanitizers will have their C++ dependency satisfied internally (LC_LOAD_DYLIB) in the libclang_rt dylib. As long as the sanitizers stay dynamic and not static, linking against C++ when enabling a sanitizer becomes over linkage. Patch by Dave Lee! llvm-svn: 274797
This commit is contained in:
parent
16284df8ec
commit
a1a36c85df
|
@ -392,24 +392,12 @@ void Darwin::addProfileRTLibs(const ArgList &Args,
|
|||
void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs,
|
||||
StringRef Sanitizer) const {
|
||||
if (!Args.hasArg(options::OPT_dynamiclib) &&
|
||||
!Args.hasArg(options::OPT_bundle)) {
|
||||
// Sanitizer runtime libraries requires C++.
|
||||
AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||
}
|
||||
|
||||
AddLinkRuntimeLib(
|
||||
Args, CmdArgs,
|
||||
(Twine("libclang_rt.") + Sanitizer + "_" +
|
||||
getOSLibraryNameSuffix() + "_dynamic.dylib").str(),
|
||||
/*AlwaysLink*/ true, /*IsEmbedded*/ false,
|
||||
/*AddRPath*/ true);
|
||||
|
||||
if (GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) {
|
||||
// Add explicit dependcy on -lc++abi, as -lc++ doesn't re-export
|
||||
// all RTTI-related symbols that UBSan uses.
|
||||
CmdArgs.push_back("-lc++abi");
|
||||
}
|
||||
}
|
||||
|
||||
void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
// RUN: | FileCheck --check-prefix=CHECK-ASAN %s
|
||||
|
||||
// CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN: stdc++
|
||||
// CHECK-ASAN-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-NOT: "-lc++"
|
||||
// CHECK-ASAN: libclang_rt.asan_osx_dynamic.dylib"
|
||||
// CHECK-ASAN: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -25,7 +26,8 @@
|
|||
// RUN: | FileCheck --check-prefix=CHECK-UBSAN %s
|
||||
|
||||
// CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-UBSAN: stdc++
|
||||
// CHECK-UBSAN-NOT: "-lstdc++"
|
||||
// CHECK-UBSAN-NOT: "-lc++"
|
||||
// CHECK-UBSAN: libclang_rt.ubsan_osx_dynamic.dylib"
|
||||
// CHECK-UBSAN: "-rpath" "@executable_path"
|
||||
// CHECK-UBSAN: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -61,7 +63,8 @@
|
|||
// RUN: %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
|
||||
|
||||
// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-IOSSIM: lc++
|
||||
// CHECK-ASAN-IOSSIM-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-IOSSIM-NOT: "-lc++"
|
||||
// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
|
||||
// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -72,7 +75,8 @@
|
|||
// RUN: | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
|
||||
|
||||
// CHECK-ASAN-TVOSSIM: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-TVOSSIM: lc++
|
||||
// CHECK-ASAN-TVOSSIM-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-TVOSSIM-NOT: "-lc++"
|
||||
// CHECK-ASAN-TVOSSIM: libclang_rt.asan_tvossim_dynamic.dylib"
|
||||
// CHECK-ASAN-TVOSSIM: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-TVOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -83,7 +87,8 @@
|
|||
// RUN: | FileCheck --check-prefix=CHECK-ASAN-WATCHOSSIM %s
|
||||
|
||||
// CHECK-ASAN-WATCHOSSIM: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-WATCHOSSIM: lc++
|
||||
// CHECK-ASAN-WATCHOSSIM-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-WATCHOSSIM-NOT: "-lc++"
|
||||
// CHECK-ASAN-WATCHOSSIM: libclang_rt.asan_watchossim_dynamic.dylib"
|
||||
// CHECK-ASAN-WATCHOSSIM: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-WATCHOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -93,7 +98,8 @@
|
|||
// RUN: %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOS %s
|
||||
|
||||
// CHECK-ASAN-IOS: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-IOS: lc++
|
||||
// CHECK-ASAN-IOS-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-IOS-NOT: "-lc++"
|
||||
// CHECK-ASAN-IOS: libclang_rt.asan_ios_dynamic.dylib"
|
||||
// CHECK-ASAN-IOS: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-IOS: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -103,7 +109,8 @@
|
|||
// RUN: %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-TVOS %s
|
||||
|
||||
// CHECK-ASAN-TVOS: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-TVOS: lc++
|
||||
// CHECK-ASAN-TVOS-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-TVOS-NOT: "-lc++"
|
||||
// CHECK-ASAN-TVOS: libclang_rt.asan_tvos_dynamic.dylib"
|
||||
// CHECK-ASAN-TVOS: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-TVOS: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
@ -113,7 +120,8 @@
|
|||
// RUN: %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-WATCHOS %s
|
||||
|
||||
// CHECK-ASAN-WATCHOS: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-ASAN-WATCHOS: lc++
|
||||
// CHECK-ASAN-WATCHOS-NOT: "-lstdc++"
|
||||
// CHECK-ASAN-WATCHOS-NOT: "-lc++"
|
||||
// CHECK-ASAN-WATCHOS: libclang_rt.asan_watchos_dynamic.dylib"
|
||||
// CHECK-ASAN-WATCHOS: "-rpath" "@executable_path"
|
||||
// CHECK-ASAN-WATCHOS: "-rpath" "{{.*}}lib{{.*}}darwin"
|
||||
|
|
Loading…
Reference in New Issue