[cfe-commits] r172856 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/ubsan-ld.c

Richard Smith richard-llvm at metafoo.co.uk
Fri Jan 18 14:09:27 PST 2013


Author: rsmith
Date: Fri Jan 18 16:09:26 2013
New Revision: 172856

URL: http://llvm.org/viewvc/llvm-project?rev=172856&view=rev
Log:
Include ubsan runtime even when building a shared library. We don't require the executable to be linked with UBSan.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/ubsan-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=172856&r1=172855&r2=172856&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 18 16:09:26 2013
@@ -1587,17 +1587,15 @@
 /// (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,

Modified: cfe/trunk/test/Driver/ubsan-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ubsan-ld.c?rev=172856&r1=172855&r2=172856&view=diff
==============================================================================
--- cfe/trunk/test/Driver/ubsan-ld.c (original)
+++ cfe/trunk/test/Driver/ubsan-ld.c Fri Jan 18 16:09:26 2013
@@ -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 \





More information about the cfe-commits mailing list