[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux
Michał Górny via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 10 03:37:35 PDT 2016
mgorny retitled this revision from "[Driver] Pass -lunwind when using libc++ + compiler-rt" to "[Driver] Pass -lunwind when using libc++ + compiler-rt on Linux".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74115.
https://reviews.llvm.org/D25402
Files:
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/linux-ld.c
Index: test/Driver/linux-ld.c
===================================================================
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -443,6 +443,20 @@
// CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
// CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
//
+// Test that libc++ combined with compiler-rt includes -lunwind
+// (and no gcc libraries).
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ -rtlib=compiler-rt \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN: | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-CLANGRT %s
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lc++" "-lunwind"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_s"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_eh"
+//
// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=i386-unknown-linux \
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -830,6 +830,8 @@
void AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const override;
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4692,6 +4692,18 @@
}
}
+void Linux::AddCXXStdlibLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ ToolChain::AddCXXStdlibLibArgs(Args, CmdArgs);
+
+ // Append -lunwind if using libc++ along with compiler-rt.
+ // With libgcc, gcc_s/gcc_eh already provides the unwinding interface,
+ // and with libstdc++ the unwinding interface is linked in implicitly.
+ if (GetCXXStdlibType(Args) == ToolChain::CST_Libcxx &&
+ GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+ CmdArgs.push_back("-lunwind");
+}
+
void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25402.74115.patch
Type: text/x-patch
Size: 2732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161010/93c69b14/attachment.bin>
More information about the cfe-commits
mailing list