diff options
author | Fangrui Song <maskray@google.com> | 2020-02-07 14:17:36 -0800 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2020-02-07 22:53:14 -0800 |
commit | 8aa3f507c38a2ccd8ed7cb33d02a6f645cdbc03a (patch) | |
tree | ddede7537664214b32f026706c0f62cbf07ecc4c /clang/lib | |
parent | 70e0935256fc173fbc57c7333727ab222af476eb (diff) | |
download | llvm-8aa3f507c38a2ccd8ed7cb33d02a6f645cdbc03a.zip llvm-8aa3f507c38a2ccd8ed7cb33d02a6f645cdbc03a.tar.gz llvm-8aa3f507c38a2ccd8ed7cb33d02a6f645cdbc03a.tar.bz2 |
[Driver] Don't pass -plugin LLVMgold.so when the linker is ld.lld
This is does not cover the case when ld is lld (e.g. /usr/bin/ld on
modern FreeBSD systems).
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/ToolChains/CommonArgs.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 122872f..0b2f8ce 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -356,25 +356,29 @@ bool tools::isUseSeparateSections(const llvm::Triple &Triple) { void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args, ArgStringList &CmdArgs, const InputInfo &Output, const InputInfo &Input, bool IsThinLTO) { - // Tell the linker to load the plugin. This has to come before AddLinkerInputs - // as gold requires -plugin to come before any -plugin-opt that -Wl might - // forward. - CmdArgs.push_back("-plugin"); + const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath()); + if (llvm::sys::path::filename(Linker) != "ld.lld" && + llvm::sys::path::stem(Linker) != "ld.lld") { + // Tell the linker to load the plugin. This has to come before + // AddLinkerInputs as gold requires -plugin to come before any -plugin-opt + // that -Wl might forward. + CmdArgs.push_back("-plugin"); #if defined(_WIN32) - const char *Suffix = ".dll"; + const char *Suffix = ".dll"; #elif defined(__APPLE__) - const char *Suffix = ".dylib"; + const char *Suffix = ".dylib"; #else - const char *Suffix = ".so"; + const char *Suffix = ".so"; #endif - SmallString<1024> Plugin; - llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) + - "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + - Suffix, - Plugin); - CmdArgs.push_back(Args.MakeArgString(Plugin)); + SmallString<1024> Plugin; + llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) + + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + + Suffix, + Plugin); + CmdArgs.push_back(Args.MakeArgString(Plugin)); + } // Try to pass driver level flags relevant to LTO code generation down to // the plugin. |