From 34436df0d0e57caafb6b0ed5911f71861b10a6eb Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Sun, 23 Apr 2017 23:44:50 +0000 Subject: [PATCH 1/7] clang: Use cmake from buildPackages --- pkgs/development/compilers/llvm/3.9/clang/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.9/clang/default.nix b/pkgs/development/compilers/llvm/3.9/clang/default.nix index 910682271103..87216e424caf 100644 --- a/pkgs/development/compilers/llvm/3.9/clang/default.nix +++ b/pkgs/development/compilers/llvm/3.9/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src, python }: +{ stdenv, fetch, libxml2, libedit, llvm, version, clang-tools-extra_src, python, buildPackages }: let gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; @@ -13,7 +13,7 @@ let mv clang-tools-extra-* $sourceRoot/tools/extra ''; - buildInputs = [ cmake libedit libxml2 llvm python ]; + buildInputs = [ buildPackages.cmake libedit libxml2 llvm python ]; cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" From 3eee6ea7c17aea50b8a1e04b95e9ee226591e38f Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Mon, 24 Apr 2017 00:01:56 +0000 Subject: [PATCH 2/7] groff: use buildPackages to fix cross compile --- pkgs/tools/text/groff/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/text/groff/default.nix b/pkgs/tools/text/groff/default.nix index df6a1119800e..aa9ece8955b4 100644 --- a/pkgs/tools/text/groff/default.nix +++ b/pkgs/tools/text/groff/default.nix @@ -1,6 +1,7 @@ { stdenv, fetchurl, perl, groff , ghostscript #for postscript and html output , psutils, netpbm #for html output +, buildPackages }: stdenv.mkDerivation rec { @@ -49,7 +50,7 @@ stdenv.mkDerivation rec { # Trick to get the build system find the proper 'native' groff # http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html preBuild = '' - makeFlags="GROFF_BIN_PATH=${groff}/bin GROFFBIN=${groff}/bin/groff" + makeFlags="GROFF_BIN_PATH=${buildPackages.groff}/bin GROFFBIN=${buildPackages.groff}/bin/groff" ''; }; From 12bbc630247f85f4fa84c100d856a712b6d7cf4d Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Sun, 23 Apr 2017 23:48:02 +0000 Subject: [PATCH 3/7] llvm-3.9: Fix cross compilation It's now possible to cross compile llvm: `nix-build -E '(import ./. { crossSystem = import ./platform.nix; }).pkgs.llvm'` --- pkgs/development/compilers/llvm/3.9/llvm.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 2c47ec5127f9..0408b9413c8a 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -17,6 +17,9 @@ , debugVersion ? false , enableSharedLibraries ? true , darwin +, buildPackages +, buildPlatform +, hostPlatform }: let @@ -39,7 +42,13 @@ in stdenv.mkDerivation rec { outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; - buildInputs = [ perl groff cmake libxml2 python libffi ] + buildInputs = [ + buildPackages.perl + buildPackages.buildPackages.cmake + buildPackages.python + groff + libxml2 + libffi ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; propagatedBuildInputs = [ ncurses zlib ]; @@ -88,6 +97,9 @@ in stdenv.mkDerivation rec { ++ stdenv.lib.optionals (isDarwin) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DCAN_TARGET_i386=false" + ] ++ stdenv.lib.optionals (buildPlatform != hostPlatform) [ + "-DCMAKE_CROSSCOMPILING=True" + "-DLLVM_TABLEGEN=${buildPackages.llvmPackages_39.llvm}/bin/llvm-tblgen" ]; postBuild = '' From fea424fea33b7b71dfc43b3297ad2d1d2da36f5a Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Tue, 25 Apr 2017 22:23:58 +0000 Subject: [PATCH 4/7] LLVM-3.9: Fix RPATH in cross compile builds This error was cause by multiple-outputs.sh not setting NIX_CROSS_LDFLAGS --- pkgs/development/compilers/llvm/3.9/llvm.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 0408b9413c8a..6c86ac0c2942 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -81,6 +81,12 @@ in stdenv.mkDerivation rec { preBuild = '' mkdir -p $out/ ln -sv $PWD/lib $out + '' + + # This is a good candidate for using the `placeholder` primitive when it's released + # This should hopefully be unnecessary once + # https://github.com/NixOS/nixpkgs/pull/25047 is merged + stdenv.lib.optionalString (buildPlatform != hostPlatform && enableSharedLibraries) '' + export NIX_CROSS_LDFLAGS="-rpath $lib/lib -rpath $lib/lib64 $NIX_CROSS_LDFLAGS" ''; cmakeFlags = with stdenv; [ From bad5ca052553aefb724e32bed1ea547b911cbb4b Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Tue, 25 Apr 2017 22:31:31 +0000 Subject: [PATCH 5/7] LLVM-3.9: Use nativeBuildInputs instead of buildPackages --- pkgs/development/compilers/llvm/3.9/clang/default.nix | 6 ++++-- pkgs/development/compilers/llvm/3.9/llvm.nix | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.9/clang/default.nix b/pkgs/development/compilers/llvm/3.9/clang/default.nix index 87216e424caf..ec2ec27df363 100644 --- a/pkgs/development/compilers/llvm/3.9/clang/default.nix +++ b/pkgs/development/compilers/llvm/3.9/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, libxml2, libedit, llvm, version, clang-tools-extra_src, python, buildPackages }: +{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src, python }: let gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; @@ -13,7 +13,9 @@ let mv clang-tools-extra-* $sourceRoot/tools/extra ''; - buildInputs = [ buildPackages.cmake libedit libxml2 llvm python ]; + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libedit libxml2 llvm python ]; cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-std=c++11" diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 6c86ac0c2942..380abc0b9b47 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -42,10 +42,13 @@ in stdenv.mkDerivation rec { outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; + nativeBuildInputs = [ + perl + cmake + python + ]; + buildInputs = [ - buildPackages.perl - buildPackages.buildPackages.cmake - buildPackages.python groff libxml2 libffi ] From 7b7ffc4999ba4b38f8090aab48a78ace0eb3424a Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Wed, 26 Apr 2017 14:01:35 +0000 Subject: [PATCH 6/7] LLVM-3.9: disable shared libraries in cross builds The current cc-wrapper script seems to have trouble setting the rpath correctly. Hopefully #25047 will fix this. --- pkgs/development/compilers/llvm/3.9/llvm.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 380abc0b9b47..96efc97323c6 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -15,13 +15,15 @@ , compiler-rt_src , libcxxabi , debugVersion ? false -, enableSharedLibraries ? true +, enableSharedLibraries ? (buildPlatform == hostPlatform) , darwin , buildPackages , buildPlatform , hostPlatform }: +assert (hostPlatform != buildPlatform) -> !enableSharedLibraries; + let src = fetch "llvm" "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"; shlib = if stdenv.isDarwin then "dylib" else "so"; @@ -84,12 +86,6 @@ in stdenv.mkDerivation rec { preBuild = '' mkdir -p $out/ ln -sv $PWD/lib $out - '' - + # This is a good candidate for using the `placeholder` primitive when it's released - # This should hopefully be unnecessary once - # https://github.com/NixOS/nixpkgs/pull/25047 is merged - stdenv.lib.optionalString (buildPlatform != hostPlatform && enableSharedLibraries) '' - export NIX_CROSS_LDFLAGS="-rpath $lib/lib -rpath $lib/lib64 $NIX_CROSS_LDFLAGS" ''; cmakeFlags = with stdenv; [ From ad778a64d7c887405e37a2ddc375dc01350dfe10 Mon Sep 17 00:00:00 2001 From: Joe Hermaszewski Date: Wed, 26 Apr 2017 13:14:00 +0000 Subject: [PATCH 7/7] LLVM-3.9: formatting --- pkgs/development/compilers/llvm/3.9/llvm.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.9/llvm.nix b/pkgs/development/compilers/llvm/3.9/llvm.nix index 96efc97323c6..964b6232fb54 100644 --- a/pkgs/development/compilers/llvm/3.9/llvm.nix +++ b/pkgs/development/compilers/llvm/3.9/llvm.nix @@ -53,8 +53,8 @@ in stdenv.mkDerivation rec { buildInputs = [ groff libxml2 - libffi ] - ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; + libffi + ] ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; propagatedBuildInputs = [ ncurses zlib ];