forked from mirrors/nixpkgs
3530837417
When using GNU binutils, clang passes the LLVMgold.so plugin to the linker for certain operations that require special support in the linker like doing link time optimization (LTO). When passing the plugin to the linker's command line, clang assumes that llvm and itself are installed in the same prefix and thus `/path/to/clang/bin/../lib/LLVMgold.so` is the plugin. Since we install clang and llvm to separate store paths, this assumption does not hold. When clang-unwrapped only had a single output, we worked around this issue by symlinking `$out/lib/LLVMgold.so` to `${llvm}/lib/LLVMgold.so`. However since we split all llvm packages into multiple outputs clang's `$out` no longer has a lib directory and clang can't discover clangs lib output on its own. As a result LTO was broken. Instead of introducing yet another hack and having a symlink to LLVMgold.so in `$out/lib` (despite having `$lib/lib` as well), we patch clang to use a hard coded path to `${libllvm.lib}/lib` for discovering `LLVMgold.so`. Resolves #123361.
15 lines
727 B
Diff
15 lines
727 B
Diff
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
index 00bd60bc24bb..17416b0bd3c0 100644
|
|
--- a/lib/Driver/ToolChains/CommonArgs.cpp
|
|
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
|
|
@@ -376,8 +376,7 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
|
|
// as gold requires -plugin to come before any -plugin-opt that -Wl might
|
|
// forward.
|
|
CmdArgs.push_back("-plugin");
|
|
- std::string Plugin =
|
|
- ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
|
|
+ std::string Plugin = "@libllvmLibdir@" "/LLVMgold.so";
|
|
CmdArgs.push_back(Args.MakeArgString(Plugin));
|
|
|
|
// Try to pass driver level flags relevant to LTO code generation down to
|