aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2019-03-19 20:01:59 +0000
committerSterling Augustine <saugustine@google.com>2019-03-19 20:01:59 +0000
commit6271606969e276f48c6965f31a46acf54e476e65 (patch)
tree78c553a12462332ae565b97163604be343e2c436 /clang/lib/Driver/ToolChain.cpp
parent77423914419162ad57bad560bf4dccf3f5759db2 (diff)
downloadllvm-6271606969e276f48c6965f31a46acf54e476e65.zip
llvm-6271606969e276f48c6965f31a46acf54e476e65.tar.gz
llvm-6271606969e276f48c6965f31a46acf54e476e65.tar.bz2
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
"clang++ hello.cc --rtlib=compiler-rt" now can works without specifying additional unwind or exception handling libraries. This reworked version of the feature no longer modifies today's default unwind library for compiler-rt: which is nothing. Rather, a user can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring the compiler. This should address the issues from the previous version. Update tests for new --unwindlib semantics. Differential Revision: https://reviews.llvm.org/D59109 llvm-svn: 356508
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 6b56271..5dff2b2 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -693,6 +693,33 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
return GetDefaultRuntimeLibType();
}
+ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
+ const ArgList &Args) const {
+ const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;
+
+ if (LibName == "none")
+ return ToolChain::UNW_None;
+ else if (LibName == "platform" || LibName == "") {
+ ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args);
+ if (RtLibType == ToolChain::RLT_CompilerRT)
+ return ToolChain::UNW_None;
+ else if (RtLibType == ToolChain::RLT_Libgcc)
+ return ToolChain::UNW_Libgcc;
+ } else if (LibName == "libunwind") {
+ if (GetRuntimeLibType(Args) == RLT_Libgcc)
+ getDriver().Diag(diag::err_drv_incompatible_unwindlib);
+ return ToolChain::UNW_CompilerRT;
+ } else if (LibName == "libgcc")
+ return ToolChain::UNW_Libgcc;
+
+ if (A)
+ getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
+ << A->getAsString(Args);
+
+ return GetDefaultUnwindLibType();
+}
+
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;