diff options
author | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-05-18 16:15:03 +0200 |
---|---|---|
committer | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-05-18 16:15:03 +0200 |
commit | 3530837417da13076a2c8412de2c0c385dfbd648 (patch) | |
tree | bc1ebce3eeea43dc1c77d70b0e7e5de623a7a66d /pkgs/development/compilers/llvm/5/clang/default.nix | |
parent | 3ff6965554e6daedca27cf6a87d35cbbbec4afb7 (diff) | |
download | nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar.gz nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar.bz2 nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar.lz nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar.xz nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.tar.zst nixpkgs-3530837417da13076a2c8412de2c0c385dfbd648.zip |
llvmPackages*.clang: fix linker invocation with LLVMgold plugin
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.
Diffstat (limited to 'pkgs/development/compilers/llvm/5/clang/default.nix')
-rw-r--r-- | pkgs/development/compilers/llvm/5/clang/default.nix | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pkgs/development/compilers/llvm/5/clang/default.nix b/pkgs/development/compilers/llvm/5/clang/default.nix index b5887a23c65..df3d2613986 100644 --- a/pkgs/development/compilers/llvm/5/clang/default.nix +++ b/pkgs/development/compilers/llvm/5/clang/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, llvm_meta, fetch, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3 +{ lib, stdenv, llvm_meta, fetch, substituteAll, cmake, libxml2, libllvm, version, clang-tools-extra_src, python3 , buildLlvmTools , fixDarwinDylibNames , enableManpages ? false @@ -43,6 +43,10 @@ let patches = [ ./purity.patch ./gnu-install-dirs.patch + (substituteAll { + src = ./LLVMgold-path.patch; + libllvmLibdir = "${libllvm.lib}/lib"; + }) ]; postPatch = '' @@ -58,12 +62,7 @@ let outputs = [ "out" "lib" "dev" "python" ]; - # Clang expects to find LLVMgold in its own prefix postInstall = '' - if [ -e ${libllvm.lib}/lib/LLVMgold.so ]; then - ln -sv ${libllvm.lib}/lib/LLVMgold.so $lib/lib - fi - ln -sv $out/bin/clang $out/bin/cpp # Move libclang to 'lib' output |