r224975 - Driver: unify addClangRT{Linux,Windows}
Saleem Abdulrasool
compnerd at compnerd.org
Mon Dec 29 18:10:37 PST 2014
Author: compnerd
Date: Mon Dec 29 20:10:36 2014
New Revision: 224975
URL: http://llvm.org/viewvc/llvm-project?rev=224975&view=rev
Log:
Driver: unify addClangRT{Linux,Windows}
The differences are pretty superficial:
- .lib vs .a extensions
- whether or not to link (potentially) incorrectly against libgcc_s
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=224975&r1=224974&r2=224975&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 29 20:10:36 2014
@@ -2124,25 +2124,23 @@ static SmallString<128> getCompilerRTLib
// This adds the static libclang_rt.builtins-arch.a directly to the command line
// FIXME: Make sure we can also emit shared objects if they're requested
// and available, check for possible errors, etc.
-static void addClangRTLinux(
- const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) {
- SmallString<128> LibClangRT = getCompilerRTLibDir(TC);
- llvm::sys::path::append(LibClangRT, Twine("libclang_rt.builtins-") +
- getArchNameForCompilerRTLib(TC) +
- ".a");
+static void addClangRT(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
+ bool IsOSWindows = TC.getTriple().isOSWindows();
+ StringRef Arch = getArchNameForCompilerRTLib(TC);
+ const char *Suffix = IsOSWindows ? ".lib" : ".a";
- CmdArgs.push_back(Args.MakeArgString(LibClangRT));
- CmdArgs.push_back("-lgcc_s");
- if (TC.getDriver().CCCIsCXX())
- CmdArgs.push_back("-lgcc_eh");
-}
-
-static void addClangRTWindows(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
SmallString<128> LibClangRT = getCompilerRTLibDir(TC);
- llvm::sys::path::append(LibClangRT, Twine("libclang_rt.builtins-") +
- getArchNameForCompilerRTLib(TC) + ".lib");
+ llvm::sys::path::append(LibClangRT,
+ Twine("libclang_rt.builtins-") + Arch + Suffix);
+
CmdArgs.push_back(Args.MakeArgString(LibClangRT));
+ if (!IsOSWindows) {
+ // FIXME: why do we link against gcc when we are using compiler-rt?
+ CmdArgs.push_back("-lgcc_s");
+ if (TC.getDriver().CCCIsCXX())
+ CmdArgs.push_back("-lgcc_eh");
+ }
}
static void addProfileRT(
@@ -7298,15 +7296,13 @@ static void AddRunTimeLibs(const ToolCha
// Make use of compiler-rt if --rtlib option is used
ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(Args);
- switch(RLT) {
+ switch (RLT) {
case ToolChain::RLT_CompilerRT:
switch (TC.getTriple().getOS()) {
default: llvm_unreachable("unsupported OS");
case llvm::Triple::Win32:
- addClangRTWindows(TC, Args, CmdArgs);
- break;
case llvm::Triple::Linux:
- addClangRTLinux(TC, Args, CmdArgs);
+ addClangRT(TC, Args, CmdArgs);
break;
}
break;
More information about the cfe-commits
mailing list