forked from OSchip/llvm-project
Include ubsan runtime even when building a shared library. We don't require the executable to be linked with UBSan.
llvm-svn: 172856
This commit is contained in:
parent
b2206e71e1
commit
f75c8b3c8d
|
@ -1587,17 +1587,15 @@ static void addMsanRTLinux(const ToolChain &TC, const ArgList &Args,
|
|||
/// (Linux).
|
||||
static void addUbsanRTLinux(const ToolChain &TC, const ArgList &Args,
|
||||
ArgStringList &CmdArgs) {
|
||||
if (!Args.hasArg(options::OPT_shared)) {
|
||||
// LibUbsan is "libclang_rt.ubsan-<ArchName>.a" in the Linux library
|
||||
// resource directory.
|
||||
SmallString<128> LibUbsan(TC.getDriver().ResourceDir);
|
||||
llvm::sys::path::append(LibUbsan, "lib", "linux",
|
||||
(Twine("libclang_rt.ubsan-") +
|
||||
TC.getArchName() + ".a"));
|
||||
CmdArgs.push_back(Args.MakeArgString(LibUbsan));
|
||||
CmdArgs.push_back("-lpthread");
|
||||
CmdArgs.push_back("-export-dynamic");
|
||||
}
|
||||
// LibUbsan is "libclang_rt.ubsan-<ArchName>.a" in the Linux library
|
||||
// resource directory.
|
||||
SmallString<128> LibUbsan(TC.getDriver().ResourceDir);
|
||||
llvm::sys::path::append(LibUbsan, "lib", "linux",
|
||||
(Twine("libclang_rt.ubsan-") +
|
||||
TC.getArchName() + ".a"));
|
||||
CmdArgs.push_back(Args.MakeArgString(LibUbsan));
|
||||
CmdArgs.push_back("-lpthread");
|
||||
CmdArgs.push_back("-export-dynamic");
|
||||
}
|
||||
|
||||
static bool shouldUseFramePointer(const ArgList &Args,
|
||||
|
|
|
@ -9,6 +9,16 @@
|
|||
// CHECK-LINUX: libclang_rt.ubsan-i386.a"
|
||||
// CHECK-LINUX: "-lpthread"
|
||||
|
||||
// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target i386-unknown-linux \
|
||||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
// RUN: -shared \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-LINUX-SHARED %s
|
||||
// CHECK-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
|
||||
// CHECK-LINUX-SHARED-NOT: "-lc"
|
||||
// CHECK-LINUX-SHARED: libclang_rt.ubsan-i386.a"
|
||||
// CHECK-LINUX-SHARED: "-lpthread"
|
||||
|
||||
// RUN: %clang -fsanitize=bounds %s -### -o %t.o 2>&1 \
|
||||
// RUN: -target i386-unknown-linux \
|
||||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
|
|
Loading…
Reference in New Issue