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:


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:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to