From 0f6ef7c41ccdb4cd14edc8e5b8be9eb877c979a0 Mon Sep 17 00:00:00 2001 From: Anthony Cowley Date: Tue, 18 Oct 2016 19:49:14 -0400 Subject: [PATCH] llvm_39: fix on darwin --- .../compilers/llvm/3.9/default.nix | 2 +- pkgs/development/compilers/llvm/3.9/llvm.nix | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.9/default.nix b/pkgs/development/compilers/llvm/3.9/default.nix index a39f013d1a9a..17351ae87366 100644 --- a/pkgs/development/compilers/llvm/3.9/default.nix +++ b/pkgs/development/compilers/llvm/3.9/default.nix @@ -1,4 +1,4 @@ -{ newScope, stdenv, isl, fetchurl, overrideCC, wrapCC }: +{ newScope, stdenv, isl, fetchurl, overrideCC, wrapCC, darwin }: let callPackage = newScope (self // { inherit stdenv isl version fetch; }); diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 22dea611c796..8086f980bcf5 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -15,10 +15,16 @@ , libcxxabi , debugVersion ? false , enableSharedLibraries ? true +, darwin }: let src = fetch "llvm" "0j49lkd5d7nnpdqzaybs2472bvcxyx0i4r3iccwf3kj2v9wk3iv6"; + shlib = if stdenv.isDarwin then "dylib" else "so"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." version)); in stdenv.mkDerivation rec { name = "llvm-${version}"; @@ -33,7 +39,8 @@ in stdenv.mkDerivation rec { outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; buildInputs = [ perl groff cmake libxml2 python libffi ] - ++ stdenv.lib.optional stdenv.isDarwin libcxxabi; + ++ stdenv.lib.optionals stdenv.isDarwin + [ libcxxabi darwin.cctools darwin.apple_sdk.libs.xpc ]; propagatedBuildInputs = [ ncurses zlib ]; @@ -70,6 +77,7 @@ in stdenv.mkDerivation rec { ++ stdenv.lib.optionals (isDarwin) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DCAN_TARGET_i386=false" + "-DCMAKE_LIBTOOL=${darwin.cctools}/bin/libtool" ]; postBuild = '' @@ -81,13 +89,17 @@ in stdenv.mkDerivation rec { postInstall = "" + stdenv.lib.optionalString (enableSharedLibraries) '' moveToOutput "lib/libLLVM-*" "$lib" - moveToOutput "lib/libLLVM.so" "$lib" + moveToOutput "lib/libLLVM.${shlib}" "$lib" substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" '' + 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 + 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 ''; enableParallelBuilding = true;