[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

Michał Górny via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 8 14:24:50 PDT 2016


mgorny created this revision.
mgorny added reviewers: ddunbar, EricWF, rsmith, phosek.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: dberris.

Include -lunwind by default when libc++ is used as the standard C++
library and compiler-rt used as the runtime library. This aims to make
it possible to build programs using '-rtlib=compiler-rt -stdlib=libc++'
out-of-the-box on platforms not having those by default, since clang
missed an unlinker library so far in this case.

This aims to match the current '-rtlib=libgcc' behavior which includes
the gcc unwinder library unconditionally (libgcc_s or libgcc_eh).
However, the unwind library is added only if libc++ is used as
the standard C++ library since libstdc++ implicitly includes
the unwinder. Furthermore, -lunwind is only used for C++ to avoid adding
unnecessary dependencies for C builds that could make bootstrap harder.


https://reviews.llvm.org/D25402

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -646,6 +646,8 @@
   switch (Type) {
   case ToolChain::CST_Libcxx:
     CmdArgs.push_back("-lc++");
+    if (GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+        CmdArgs.push_back("-lunwind");
     break;
 
   case ToolChain::CST_Libstdcxx:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25402.74048.patch
Type: text/x-patch
Size: 412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161008/d8992e68/attachment.bin>


More information about the cfe-commits mailing list