summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains.cpp
diff options
context:
space:
mode:
authorJonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de>2016-07-27 08:15:54 +0000
committerJonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de>2016-07-27 08:15:54 +0000
commitd196fa524fa483a6195f6f079b0ee82dba03db1f (patch)
treec49889501e16de7bc63ef8f8d0e35dd29d99ca96 /clang/lib/Driver/ToolChains.cpp
parent7094aa4f8d9cf64c56e07966b993c593bc8c73d8 (diff)
downloadbcm5719-llvm-d196fa524fa483a6195f6f079b0ee82dba03db1f.tar.gz
bcm5719-llvm-d196fa524fa483a6195f6f079b0ee82dba03db1f.zip
Support setting default value for -rtlib at build time
This patch introduces a new cmake variable: CLANG_DEFAULT_RTLIB, thru which we can specify a default value for -rtlib (libgcc or compiler-rt) at build time, just like how we set the default C++ stdlib thru CLANG_DEFAULT_CXX_STDLIB. With these two options, we can configure clang to build binaries on Linux that have no runtime dependence on any gcc libs (libstdc++ or libgcc_s). Patch by Lei Zhang! Differential Revision: https://reviews.llvm.org/D22663 llvm-svn: 276848
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r--clang/lib/Driver/ToolChains.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index f05261aef30..610285e1f40 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -403,18 +403,23 @@ void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
/*AddRPath*/ true);
}
+ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
+ const ArgList &Args) const {
+ if (Arg* A = Args.getLastArg(options::OPT_rtlib_EQ)) {
+ StringRef Value = A->getValue();
+ if (Value != "compiler-rt")
+ getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
+ << Value << "darwin";
+ }
+
+ return ToolChain::RLT_CompilerRT;
+}
+
void DarwinClang::AddLinkRuntimeLibArgs(const llvm::Triple &EffectiveTriple,
const ArgList &Args,
ArgStringList &CmdArgs) const {
- // Darwin only supports the compiler-rt based runtime libraries.
- switch (GetRuntimeLibType(Args)) {
- case ToolChain::RLT_CompilerRT:
- break;
- default:
- getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
- << Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "darwin";
- return;
- }
+ // Call once to ensure diagnostic is printed if wrong value was specified
+ GetRuntimeLibType(Args);
// Darwin doesn't support real static executables, don't link any runtime
// libraries with -static.
OpenPOWER on IntegriCloud