diff options
author | Michal Gorny <mgorny@gentoo.org> | 2016-10-07 17:08:06 +0000 |
---|---|---|
committer | Michal Gorny <mgorny@gentoo.org> | 2016-10-07 17:08:06 +0000 |
commit | 81684a0676efc6cfe39fd734055163f92c1e5d5f (patch) | |
tree | 2d809c0be66e2fcdd37eea34026d985ccee7696d /clang/lib/Driver/Driver.cpp | |
parent | 848556a0e26eb503d6d6ae3a976ae0208b02f9a2 (diff) | |
download | bcm5719-llvm-81684a0676efc6cfe39fd734055163f92c1e5d5f.tar.gz bcm5719-llvm-81684a0676efc6cfe39fd734055163f92c1e5d5f.zip |
[Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.
The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:
clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name)
in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.
Differential Revision: https://reviews.llvm.org/D25338
llvm-svn: 283572
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index f26d61f1d7d..fd0bcfbeba5 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -994,7 +994,15 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { } if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) { - llvm::outs() << GetFilePath("libgcc.a", TC) << "\n"; + ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs()); + switch (RLT) { + case ToolChain::RLT_CompilerRT: + llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n"; + break; + case ToolChain::RLT_Libgcc: + llvm::outs() << GetFilePath("libgcc.a", TC) << "\n"; + break; + } return false; } |