diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-12-30 02:10:36 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-12-30 02:10:36 +0000 |
commit | 8d7ade7062455575882790d499c7e5ca5057a088 (patch) | |
tree | ccf3c46fbc57e8af61b995f188148699e09cf308 /clang/lib/Driver/Tools.cpp | |
parent | 8d26b72aca165c3d9d97fce44973953600d196e5 (diff) | |
download | bcm5719-llvm-8d7ade7062455575882790d499c7e5ca5057a088.tar.gz bcm5719-llvm-8d7ade7062455575882790d499c7e5ca5057a088.zip |
Driver: unify addClangRT{Linux,Windows}
The differences are pretty superficial:
- .lib vs .a extensions
- whether or not to link (potentially) incorrectly against libgcc_s
llvm-svn: 224975
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 5212d46345a..6ee9a9204cc 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2124,25 +2124,23 @@ static SmallString<128> getCompilerRTLibDir(const ToolChain &TC) { // 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 ToolChain &TC, const Driver &D, // 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; |