diff options
author | Dan Peebles <pumpkin@me.com> | 2017-10-06 01:26:19 -0400 |
---|---|---|
committer | Dan Peebles <pumpkin@me.com> | 2017-10-08 16:13:46 -0400 |
commit | b426c85ce2f12b81b923bf8d0539d15a41b3a341 (patch) | |
tree | f5e463c3cdc9e94fb2484a604594a66c93aec39e /pkgs/development/compilers | |
parent | 0be2928ac9f8fa7ad2245785e586381ba8002585 (diff) | |
download | nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar.gz nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar.bz2 nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar.lz nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar.xz nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.tar.zst nixlib-b426c85ce2f12b81b923bf8d0539d15a41b3a341.zip |
Get rid of most @rpath nonsense on Darwin
This requires some small changes in the stdenv, then working around the weird choice LLVM made to hardcode @rpath in its install name, and then lets us remove a ton of annoying workaround hacks in many of our Go packages. With any luck this will mean less hackery going forward.
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r-- | pkgs/development/compilers/llvm/3.5/llvm.nix | 6 | ||||
-rw-r--r-- | pkgs/development/compilers/llvm/3.8/llvm.nix | 7 | ||||
-rw-r--r-- | pkgs/development/compilers/llvm/3.9/llvm.nix | 6 | ||||
-rw-r--r-- | pkgs/development/compilers/llvm/4/llvm.nix | 6 | ||||
-rw-r--r-- | pkgs/development/compilers/llvm/5/llvm.nix | 6 |
5 files changed, 23 insertions, 8 deletions
diff --git a/pkgs/development/compilers/llvm/3.5/llvm.nix b/pkgs/development/compilers/llvm/3.5/llvm.nix index 0be3af192b42..94f39183345f 100644 --- a/pkgs/development/compilers/llvm/3.5/llvm.nix +++ b/pkgs/development/compilers/llvm/3.5/llvm.nix @@ -33,6 +33,12 @@ in stdenv.mkDerivation rec { propagatedBuildInputs = [ ncurses zlib ]; + prePatch = '' + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" + ''; + # hacky fix: created binaries need to be run before installation preBuild = '' mkdir -p $out/ diff --git a/pkgs/development/compilers/llvm/3.8/llvm.nix b/pkgs/development/compilers/llvm/3.8/llvm.nix index 558bdcc5ce6a..f8b8948e749e 100644 --- a/pkgs/development/compilers/llvm/3.8/llvm.nix +++ b/pkgs/development/compilers/llvm/3.8/llvm.nix @@ -44,7 +44,11 @@ in stdenv.mkDerivation rec { # 10.9. This is a temporary measure until nixpkgs darwin support is # updated. postPatch = stdenv.lib.optionalString stdenv.isDarwin '' - sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc + sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc + + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$out/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" ''; # hacky fix: created binaries need to be run before installation @@ -75,7 +79,6 @@ in stdenv.mkDerivation rec { ''; postInstall = stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' - install_name_tool -id $out/lib/libLLVM.dylib $out/lib/libLLVM.dylib ln -s $out/lib/libLLVM.dylib $out/lib/libLLVM-${version}.dylib ''; diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 5f90e508c5e2..809c49ac24a2 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -82,6 +82,10 @@ in stdenv.mkDerivation rec { + stdenv.lib.optionalString stdenv.isDarwin '' substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + + substituteInPlace CMakeLists.txt \ + --replace 'set(CMAKE_INSTALL_NAME_DIR "@rpath")' "set(CMAKE_INSTALL_NAME_DIR "$lib/lib")" \ + --replace 'set(CMAKE_INSTALL_RPATH "@executable_path/../lib")' "" '' # Patch llvm-config to return correct library path based on --link-{shared,static}. + stdenv.lib.optionalString (enableSharedLibraries) '' @@ -130,8 +134,6 @@ in stdenv.mkDerivation rec { + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" - install_name_tool -id $lib/lib/libLLVM.dylib $lib/lib/libLLVM.dylib - install_name_tool -change @rpath/libLLVM.dylib $lib/lib/libLLVM.dylib $out/bin/llvm-config ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${version}.dylib ''; diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index 20ab9b44b65c..e90603ffefae 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -58,6 +58,10 @@ in stdenv.mkDerivation rec { postPatch = stdenv.lib.optionalString stdenv.isDarwin '' substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir INSTALL_NAME_DIR "$lib/lib")" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" '' # Patch llvm-config to return correct library path based on --link-{shared,static}. + stdenv.lib.optionalString (enableSharedLibraries) '' @@ -121,8 +125,6 @@ in stdenv.mkDerivation rec { + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" - install_name_tool -id $lib/lib/libLLVM.dylib $lib/lib/libLLVM.dylib - install_name_tool -change @rpath/libLLVM.dylib $lib/lib/libLLVM.dylib $out/bin/llvm-config ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib ''; diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix index 946c04a2ab4e..011eab5678c1 100644 --- a/pkgs/development/compilers/llvm/5/llvm.nix +++ b/pkgs/development/compilers/llvm/5/llvm.nix @@ -58,6 +58,10 @@ in stdenv.mkDerivation rec { postPatch = stdenv.lib.optionalString stdenv.isDarwin '' substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' + + substituteInPlace cmake/modules/AddLLVM.cmake \ + --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir INSTALL_NAME_DIR "$lib/lib")" \ + --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" '' # Patch llvm-config to return correct library path based on --link-{shared,static}. + stdenv.lib.optionalString (enableSharedLibraries) '' @@ -129,8 +133,6 @@ in stdenv.mkDerivation rec { + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" - install_name_tool -id $lib/lib/libLLVM.dylib $lib/lib/libLLVM.dylib - install_name_tool -change @rpath/libLLVM.dylib $lib/lib/libLLVM.dylib $out/bin/llvm-config ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib ''; |