diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix index 562f9e3457dd4..3405ee27112d7 100644 --- a/pkgs/development/compilers/llvm/4/default.nix +++ b/pkgs/development/compilers/llvm/4/default.nix @@ -1,6 +1,6 @@ { lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook , libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun -, darwin +, darwin, hostLLVM }: let @@ -23,7 +23,7 @@ let drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ }; llvm = callPackage ./llvm.nix { - inherit compiler-rt_src stdenv; + inherit compiler-rt_src stdenv hostLLVM; }; clang-unwrapped = callPackage ./clang { diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index bc8453f743ade..709c8db846537 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -17,6 +17,7 @@ , enableManpages ? false , enableSharedLibraries ? true , darwin +, hostLLVM }: let @@ -40,7 +41,8 @@ in stdenv.mkDerivation (rec { ++ stdenv.lib.optional enableSharedLibraries "lib"; nativeBuildInputs = [ cmake python ] - ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx + ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) hostLLVM; buildInputs = [ libxml2 libffi ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; @@ -122,6 +124,10 @@ in stdenv.mkDerivation (rec { "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}" "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}" + ] + ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen" ]; postBuild = '' diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix index 13e1d2308f8c6..e4eac9d9f57ec 100644 --- a/pkgs/development/compilers/llvm/5/default.nix +++ b/pkgs/development/compilers/llvm/5/default.nix @@ -1,6 +1,6 @@ { lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook , libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun -, darwin +, darwin, hostLLVM }: let @@ -23,7 +23,7 @@ let drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ }; llvm = callPackage ./llvm.nix { - inherit compiler-rt_src stdenv; + inherit compiler-rt_src stdenv hostLLVM; }; clang-unwrapped = callPackage ./clang { diff --git a/pkgs/development/compilers/llvm/5/llvm.nix b/pkgs/development/compilers/llvm/5/llvm.nix index ac575a0bf7aa5..8c7129af7b949 100644 --- a/pkgs/development/compilers/llvm/5/llvm.nix +++ b/pkgs/development/compilers/llvm/5/llvm.nix @@ -17,6 +17,7 @@ , enableManpages ? false , enableSharedLibraries ? true , darwin +, hostLLVM }: let @@ -40,7 +41,9 @@ in stdenv.mkDerivation (rec { ++ stdenv.lib.optional enableSharedLibraries "lib"; nativeBuildInputs = [ cmake python ] - ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx + ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) + hostLLVM; buildInputs = [ libxml2 libffi ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; @@ -115,6 +118,10 @@ in stdenv.mkDerivation (rec { "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}" "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}" + ] + ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen" ]; postBuild = '' @@ -148,7 +155,9 @@ in stdenv.mkDerivation (rec { ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib ''; - doCheck = stdenv.isLinux && (!stdenv.isi686); + doCheck = stdenv.isLinux + && (!stdenv.isi686) + && (stdenv.buildPlatform == stdenv.hostPlatform); checkTarget = "check-all"; diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index cfa9e9e15fcf1..58bc3da43d8a5 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -1,6 +1,6 @@ { lowPrio, newScope, stdenv, targetPlatform, cmake, libstdcxxHook , libxml2, python2, isl, fetchurl, overrideCC, wrapCC, ccWrapperFun -, darwin +, darwin, hostLLVM }: let @@ -23,7 +23,7 @@ let drv // { man = drv-manpages.out; /*outputs = drv.outputs ++ ["man"];*/ }; llvm = callPackage ./llvm.nix { - inherit compiler-rt_src stdenv; + inherit compiler-rt_src stdenv hostLLVM; }; clang-unwrapped = callPackage ./clang { diff --git a/pkgs/development/compilers/llvm/6/llvm.nix b/pkgs/development/compilers/llvm/6/llvm.nix index 7cb3e88c2f85d..22c41e3bfb9d2 100644 --- a/pkgs/development/compilers/llvm/6/llvm.nix +++ b/pkgs/development/compilers/llvm/6/llvm.nix @@ -18,6 +18,7 @@ , enableSharedLibraries ? true , enableWasm ? true , darwin +, hostLLVM }: let @@ -41,7 +42,8 @@ in stdenv.mkDerivation (rec { ++ stdenv.lib.optional enableSharedLibraries "lib"; nativeBuildInputs = [ cmake python ] - ++ stdenv.lib.optional enableManpages python.pkgs.sphinx; + ++ stdenv.lib.optional enableManpages python.pkgs.sphinx + ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) hostLLVM; buildInputs = [ libxml2 libffi ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; @@ -114,8 +116,13 @@ in stdenv.mkDerivation (rec { "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}" "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.targetPlatform.config}" "-DTARGET_TRIPLE=${stdenv.targetPlatform.config}" - ] ++ stdenv.lib.optional enableWasm - "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly" + ] + ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform)[ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${hostLLVM}/bin/llvm-tblgen" + ] + ++ stdenv.lib.optional enableWasm + "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly" ; postBuild = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1129a984d2711..a6c44796af33d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6708,12 +6708,14 @@ with pkgs; llvmPackages_4 = callPackage ../development/compilers/llvm/4 ({ inherit (stdenvAdapters) overrideCC; + hostLLVM = buildPackages.llvmPackages_4.llvm; } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { stdenv = overrideCC stdenv gcc6; }); llvmPackages_5 = callPackage ../development/compilers/llvm/5 ({ inherit (stdenvAdapters) overrideCC; + hostLLVM = buildPackages.llvmPackages_5.llvm; } // stdenv.lib.optionalAttrs stdenv.isDarwin { cmake = cmake.override { isBootstrap = true; @@ -6727,6 +6729,7 @@ with pkgs; llvmPackages_6 = callPackage ../development/compilers/llvm/6 ({ inherit (stdenvAdapters) overrideCC; + hostLLVM = buildPackages.llvmPackages_6.llvm; } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4' });