From 8f970d09fe8e895b6bb7dbf52f80411a45504b19 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 22 Jun 2017 14:52:35 -0400 Subject: ghcHEAD: Actually split docs into their own output I put `outputs = ...` in the wrong spot in the last PR, oops. Sorry about that. --- pkgs/development/compilers/ghc/head.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 3e1aada22eb1..53069619ffb0 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -15,8 +15,6 @@ let version = "8.1.20170106"; rev = "b4f2afe70ddbd0576b4eba3f82ba1ddc52e9b3bd"; - outputs = [ "out" "doc" ]; - commonPreConfigure = '' echo ${version} >VERSION echo ${rev} >GIT_COMMIT_ID @@ -77,6 +75,8 @@ in stdenv.mkDerivation (rec { done ''; + outputs = [ "out" "doc" ]; + passthru = { inherit bootPkgs; } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { -- cgit 1.4.1 From c4ba2e3ef691c349bcce2b1e8b76a0bcd253544c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 21 May 2017 14:51:02 -0400 Subject: cc-wrapper: Remove `stdenv.is*` for `targetPlatform.is*` Modify bootstrapping stdenvs to make sure `targetPlatform` also passed. --- pkgs/build-support/cc-wrapper/default.nix | 11 ++++++----- pkgs/stdenv/darwin/default.nix | 2 ++ pkgs/stdenv/freebsd/default.nix | 1 + pkgs/stdenv/linux/default.nix | 2 ++ pkgs/stdenv/native/default.nix | 1 + pkgs/stdenv/nix/default.nix | 1 + 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index e56f1f9a7d4a..6a47836b171f 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -10,6 +10,7 @@ , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , dyld ? null # TODO: should this be a setup-hook on dyld? , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null +, targetPlatform }: with stdenv.lib; @@ -35,7 +36,7 @@ let # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. coreutils_bin = if nativeTools then "" else getBin coreutils; - default_cxx_stdlib_compile=optionalString (stdenv.isLinux && !(cc.isGNU or false)) + default_cxx_stdlib_compile=optionalString (targetPlatform.isLinux && !(cc.isGNU or false)) "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)"; in @@ -78,7 +79,7 @@ stdenv.mkDerivation { } '' - + optionalString (!nativeLibc) (if (!stdenv.isDarwin) then '' + + optionalString (!nativeLibc) (if (!targetPlatform.isDarwin) then '' dynamicLinker="${libc_lib}/lib/$dynamicLinker" echo $dynamicLinker > $out/nix-support/dynamic-linker @@ -117,7 +118,7 @@ stdenv.mkDerivation { '' + (if nativeTools then '' - ccPath="${if stdenv.isDarwin then cc else nativePrefix}/bin" + ccPath="${if targetPlatform.isDarwin then cc else nativePrefix}/bin" ldPath="${nativePrefix}/bin" '' else '' echo $cc > $out/nix-support/orig-cc @@ -166,7 +167,7 @@ stdenv.mkDerivation { echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs '' - + optionalString (stdenv.isSunOS && nativePrefix != "") '' + + optionalString (targetPlatform.isSunOS && nativePrefix != "") '' # Solaris needs an additional ld wrapper. ldPath="${nativePrefix}/bin" exec="$ldPath/ld" @@ -271,7 +272,7 @@ stdenv.mkDerivation { (if stdenv.system == "i686-linux" then "ld-linux.so.2" else if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else # ARM with a wildcard, which can be "" or "-armhf". - if stdenv.isArm then "ld-linux*.so.3" else + if targetPlatform.isArm32 then "ld-linux*.so.3" else if stdenv.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else if stdenv.system == "powerpc-linux" then "ld.so.1" else if stdenv.system == "mips64el-linux" then "ld.so.1" else diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index fba5afd4f6ec..1592426b6e39 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -73,6 +73,7 @@ in rec { nativeTools = true; nativePrefix = bootstrapTools; nativeLibc = false; + targetPlatform = localSystem; libc = last.pkgs.darwin.Libsystem; isClang = true; cc = { name = "clang-9.9.9"; outPath = bootstrapTools; }; @@ -295,6 +296,7 @@ in rec { inherit shell; nativeTools = false; nativeLibc = false; + targetPlatform = localSystem; inherit (pkgs) coreutils binutils gnugrep; inherit (pkgs.darwin) dyld; cc = pkgs.llvmPackages.clang-unwrapped; diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix index 474a467e90c3..20be86e5f963 100644 --- a/pkgs/stdenv/freebsd/default.nix +++ b/pkgs/stdenv/freebsd/default.nix @@ -77,6 +77,7 @@ let inherit (localSystem) system; in nativeTools = true; nativePrefix = "/usr"; nativeLibc = true; + targetPlatform = localSystem; inherit (prevStage) stdenv; cc = { name = "clang-9.9.9"; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index b3399cc29b34..b23d1cd01737 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -76,6 +76,7 @@ let else lib.makeOverridable (import ../../build-support/cc-wrapper) { nativeTools = false; nativeLibc = false; + targetPlatform = localSystem; cc = prevStage.gcc-unwrapped; isGNU = true; libc = prevStage.glibc; @@ -239,6 +240,7 @@ in nativeTools = false; nativeLibc = false; isGNU = true; + targetPlatform = localSystem; cc = prevStage.gcc-unwrapped; libc = self.glibc; inherit (self) stdenv binutils coreutils gnugrep; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 77c868a02f88..3bcd0687bc6e 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -125,6 +125,7 @@ in "i686-solaris" = "/usr/gnu"; "x86_64-solaris" = "/opt/local/gcc47"; }.${system} or "/usr"; + targetPlatform = localSystem; inherit stdenv; }; diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index ef088ecbf644..2363fb966e7a 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -30,6 +30,7 @@ bootStages ++ [ nativeTools = false; nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; nativeLibc = true; + targetPlatform = localSystem; inherit stdenv; inherit (prevStage) binutils coreutils gnugrep; cc = prevStage.gcc.cc; -- cgit 1.4.1 From 459f1c60f5e53acb96123a7da8463d1e21093426 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 13 Feb 2017 18:01:04 -0500 Subject: cc-wrapper: Learn about target prefixes This is first step towards getting rid of gcc-wrapper-cross --- pkgs/build-support/cc-wrapper/default.nix | 85 +++++++++++++++++-------------- pkgs/stdenv/darwin/default.nix | 2 + pkgs/stdenv/freebsd/default.nix | 1 + pkgs/stdenv/linux/default.nix | 2 + pkgs/stdenv/native/default.nix | 1 + pkgs/stdenv/nix/default.nix | 1 + 6 files changed, 53 insertions(+), 39 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 6a47836b171f..29766a7fe020 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -10,7 +10,7 @@ , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , dyld ? null # TODO: should this be a setup-hook on dyld? , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null -, targetPlatform +, hostPlatform, targetPlatform }: with stdenv.lib; @@ -24,6 +24,12 @@ assert !nativeLibc -> libc != null; assert cc.langVhdl or false -> zlib != null; let + # Prefix for binaries. Customarily ends with a dash separator. + # + # TODO(@Ericson2314) Make unconditional, or optional but always true by + # default. + prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform) + (targetPlatform.config + "-"); ccVersion = (builtins.parseDrvName cc.name).version; ccName = (builtins.parseDrvName cc.name).name; @@ -41,9 +47,9 @@ let in stdenv.mkDerivation { - name = - (if name != "" then name else ccName + "-wrapper") + - (if cc != null && ccVersion != "" then "-" + ccVersion else ""); + name = prefix + + (if name != "" then name else "${ccName}-wrapper") + + (stdenv.lib.optionalString (cc != null && ccVersion != "") "-${ccVersion}"); preferLocalBuild = true; @@ -52,7 +58,8 @@ stdenv.mkDerivation { passthru = { - inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile; + inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile + prefix; emacsBufferSetup = pkgs: '' ; We should handle propagation here too @@ -170,7 +177,7 @@ stdenv.mkDerivation { + optionalString (targetPlatform.isSunOS && nativePrefix != "") '' # Solaris needs an additional ld wrapper. ldPath="${nativePrefix}/bin" - exec="$ldPath/ld" + exec="$ldPath/${prefix}ld" wrap ld-solaris ${./ld-solaris-wrapper.sh} '') @@ -178,72 +185,72 @@ stdenv.mkDerivation { # Create a symlink to as (the assembler). This is useful when a # cc-wrapper is installed in a user environment, as it ensures that # the right assembler is called. - if [ -e $ldPath/as ]; then - ln -s $ldPath/as $out/bin/as + if [ -e $ldPath/${prefix}as ]; then + ln -s $ldPath/${prefix}as $out/bin/${prefix}as fi - wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} + wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld} - if [ -e ${binutils_bin}/bin/ld.gold ]; then - wrap ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.gold + if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then + wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold fi if [ -e ${binutils_bin}/bin/ld.bfd ]; then - wrap ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/ld.bfd + wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd fi - export real_cc=cc - export real_cxx=c++ + export real_cc=${prefix}cc + export real_cxx=${prefix}c++ export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}" - if [ -e $ccPath/gcc ]; then - wrap gcc ${./cc-wrapper.sh} $ccPath/gcc - ln -s gcc $out/bin/cc - export real_cc=gcc - export real_cxx=g++ + if [ -e $ccPath/${prefix}gcc ]; then + wrap ${prefix}gcc ${./cc-wrapper.sh} $ccPath/${prefix}gcc + ln -s ${prefix}gcc $out/bin/${prefix}cc + export real_cc=${prefix}gcc + export real_cxx=${prefix}g++ elif [ -e $ccPath/clang ]; then - wrap clang ${./cc-wrapper.sh} $ccPath/clang - ln -s clang $out/bin/cc + wrap ${prefix}clang ${./cc-wrapper.sh} $ccPath/clang + ln -s ${prefix}clang $out/bin/${prefix}cc export real_cc=clang export real_cxx=clang++ fi - if [ -e $ccPath/g++ ]; then - wrap g++ ${./cc-wrapper.sh} $ccPath/g++ - ln -s g++ $out/bin/c++ + if [ -e $ccPath/${prefix}g++ ]; then + wrap ${prefix}g++ ${./cc-wrapper.sh} $ccPath/${prefix}g++ + ln -s ${prefix}g++ $out/bin/${prefix}c++ elif [ -e $ccPath/clang++ ]; then - wrap clang++ ${./cc-wrapper.sh} $ccPath/clang++ - ln -s clang++ $out/bin/c++ + wrap ${prefix}clang++ ${./cc-wrapper.sh} $ccPath/clang++ + ln -s ${prefix}clang++ $out/bin/${prefix}c++ fi if [ -e $ccPath/cpp ]; then - wrap cpp ${./cc-wrapper.sh} $ccPath/cpp + wrap ${prefix}cpp ${./cc-wrapper.sh} $ccPath/cpp fi '' + optionalString cc.langFortran or false '' - wrap gfortran ${./cc-wrapper.sh} $ccPath/gfortran - ln -sv gfortran $out/bin/g77 - ln -sv gfortran $out/bin/f77 + wrap ${prefix}gfortran ${./cc-wrapper.sh} $ccPath/${prefix}gfortran + ln -sv ${prefix}gfortran $out/bin/${prefix}g77 + ln -sv ${prefix}gfortran $out/bin/${prefix}f77 '' + optionalString cc.langJava or false '' - wrap gcj ${./cc-wrapper.sh} $ccPath/gcj + wrap ${prefix}gcj ${./cc-wrapper.sh} $ccPath/${prefix}gcj '' + optionalString cc.langGo or false '' - wrap gccgo ${./cc-wrapper.sh} $ccPath/gccgo + wrap ${prefix}gccgo ${./cc-wrapper.sh} $ccPath/${prefix}gccgo '' + optionalString cc.langAda or false '' - wrap gnatgcc ${./cc-wrapper.sh} $ccPath/gnatgcc - wrap gnatmake ${./gnat-wrapper.sh} $ccPath/gnatmake - wrap gnatbind ${./gnat-wrapper.sh} $ccPath/gnatbind - wrap gnatlink ${./gnatlink-wrapper.sh} $ccPath/gnatlink + wrap ${prefix}gnatgcc ${./cc-wrapper.sh} $ccPath/${prefix}gnatgcc + wrap ${prefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${prefix}gnatmake + wrap ${prefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${prefix}gnatbind + wrap ${prefix}gnatlink ${./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink '' + optionalString cc.langVhdl or false '' - ln -s $ccPath/ghdl $out/bin/ghdl + ln -s $ccPath/${prefix}ghdl $out/bin/${prefix}ghdl '' + '' @@ -253,10 +260,10 @@ stdenv.mkDerivation { # some linkers on some platforms don't support specific -z flags hardening_unsupported_flags="" - if [[ "$($ldPath/ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then + if [[ "$($ldPath/${prefix}ld -z now 2>&1 || true)" =~ un(recognized|known)\ option ]]; then hardening_unsupported_flags+=" bindnow" fi - if [[ "$($ldPath/ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then + if [[ "$($ldPath/${prefix}ld -z relro 2>&1 || true)" =~ un(recognized|known)\ option ]]; then hardening_unsupported_flags+=" relro" fi diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 1592426b6e39..bce332b67616 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -73,6 +73,7 @@ in rec { nativeTools = true; nativePrefix = bootstrapTools; nativeLibc = false; + hostPlatform = localSystem; targetPlatform = localSystem; libc = last.pkgs.darwin.Libsystem; isClang = true; @@ -296,6 +297,7 @@ in rec { inherit shell; nativeTools = false; nativeLibc = false; + hostPlatform = localSystem; targetPlatform = localSystem; inherit (pkgs) coreutils binutils gnugrep; inherit (pkgs.darwin) dyld; diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix index 20be86e5f963..389a5b9985fe 100644 --- a/pkgs/stdenv/freebsd/default.nix +++ b/pkgs/stdenv/freebsd/default.nix @@ -77,6 +77,7 @@ let inherit (localSystem) system; in nativeTools = true; nativePrefix = "/usr"; nativeLibc = true; + hostPlatform = localSystem; targetPlatform = localSystem; inherit (prevStage) stdenv; cc = { diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index b23d1cd01737..b116a48a2bd6 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -76,6 +76,7 @@ let else lib.makeOverridable (import ../../build-support/cc-wrapper) { nativeTools = false; nativeLibc = false; + hostPlatform = localSystem; targetPlatform = localSystem; cc = prevStage.gcc-unwrapped; isGNU = true; @@ -240,6 +241,7 @@ in nativeTools = false; nativeLibc = false; isGNU = true; + hostPlatform = localSystem; targetPlatform = localSystem; cc = prevStage.gcc-unwrapped; libc = self.glibc; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 3bcd0687bc6e..b21da1cd522b 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -125,6 +125,7 @@ in "i686-solaris" = "/usr/gnu"; "x86_64-solaris" = "/opt/local/gcc47"; }.${system} or "/usr"; + hostPlatform = localSystem; targetPlatform = localSystem; inherit stdenv; }; diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index 2363fb966e7a..7ab797ce91ba 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -30,6 +30,7 @@ bootStages ++ [ nativeTools = false; nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; nativeLibc = true; + hostPlatform = localSystem; targetPlatform = localSystem; inherit stdenv; inherit (prevStage) binutils coreutils gnugrep; -- cgit 1.4.1 From d70e7263f47e890a350f50686bbf38e5f342cf37 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 22 May 2017 20:59:39 -0400 Subject: cc-wrapper: Simplify and correct logic to chose dynamic linker library --- pkgs/build-support/cc-wrapper/default.nix | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 29766a7fe020..c58523d3981c 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -274,31 +274,27 @@ stdenv.mkDerivation { + extraBuildCommands; # The dynamic linker has different names on different Linux platforms. + # + # TODO(1b62c9c06173f4d5e6b090e5ae0c68fa5f478faf): This is not the best way to + # do this. I think the reference should be the style in the gcc-cross-wrapper, + # but to keep a stable stdenv now I do this sufficient if/else. dynamicLinker = if !nativeLibc then - (if stdenv.system == "i686-linux" then "ld-linux.so.2" else - if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else + (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else + if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else # ARM with a wildcard, which can be "" or "-armhf". - if targetPlatform.isArm32 then "ld-linux*.so.3" else - if stdenv.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else - if stdenv.system == "powerpc-linux" then "ld.so.1" else - if stdenv.system == "mips64el-linux" then "ld.so.1" else - if stdenv.system == "x86_64-darwin" then "/usr/lib/dyld" else + if targetPlatform.isArm32 then "ld-linux*.so.3" else + if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else + if targetPlatform.system == "powerpc-linux" then "ld.so.1" else + if targetPlatform.system == "mips64el-linux" then "ld.so.1" else + if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else + if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else abort "Don't know the name of the dynamic linker for this platform.") else ""; crossAttrs = { shell = shell.crossDrv + shell.crossDrv.shellPath; libc = stdenv.ccCross.libc; - # - # This is not the best way to do this. I think the reference should be - # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I - # do this sufficient if/else. - dynamicLinker = - (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else - if stdenv.cross.arch == "mips" then "ld.so.1" else - if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else - abort "don't know the name of the dynamic linker for this platform"); }; meta = -- cgit 1.4.1 From 04a3cad968fccc11fd07997cd5b496f4c482aae7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 22 May 2017 20:59:39 -0400 Subject: cc-wrapper: Add support for no libc whatsoever --- pkgs/build-support/cc-wrapper/default.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index c58523d3981c..86314c5130fb 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -5,7 +5,7 @@ # script that sets up the right environment variables so that the # compiler and the linker just "work". -{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" +{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" , cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , dyld ? null # TODO: should this be a setup-hook on dyld? @@ -18,7 +18,8 @@ with stdenv.lib; assert nativeTools -> nativePrefix != ""; assert !nativeTools -> cc != null && binutils != null && coreutils != null && gnugrep != null; -assert !nativeLibc -> libc != null; +assert !(nativeLibc && noLibc); +assert (noLibc || nativeLibc) == (libc == null); # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. assert cc.langVhdl or false -> zlib != null; @@ -34,9 +35,9 @@ let ccVersion = (builtins.parseDrvName cc.name).version; ccName = (builtins.parseDrvName cc.name).name; - libc_bin = if nativeLibc then null else getBin libc; - libc_dev = if nativeLibc then null else getDev libc; - libc_lib = if nativeLibc then null else getLib libc; + libc_bin = if libc == null then null else getBin libc; + libc_dev = if libc == null then null else getDev libc; + libc_lib = if libc == null then null else getLib libc; cc_solib = getLib cc; binutils_bin = if nativeTools then "" else getBin binutils; # The wrapper scripts use 'cat' and 'grep', so we may need coreutils. @@ -86,7 +87,7 @@ stdenv.mkDerivation { } '' - + optionalString (!nativeLibc) (if (!targetPlatform.isDarwin) then '' + + optionalString (libc != null) (if (!targetPlatform.isDarwin) then '' dynamicLinker="${libc_lib}/lib/$dynamicLinker" echo $dynamicLinker > $out/nix-support/dynamic-linker @@ -104,7 +105,7 @@ stdenv.mkDerivation { echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook '') - + optionalString (!nativeLibc) '' + + optionalString (libc != null) '' # The "-B${libc_lib}/lib/" flag is a quick hack to force gcc to link # against the crt1.o from our own glibc, rather than the one in # /usr/lib. (This is only an issue when using an `impure' @@ -169,7 +170,7 @@ stdenv.mkDerivation { # Propagate the wrapped cc so that if you install the wrapper, # you get tools like gcov, the manpages, etc. as well (including # for binutils and Glibc). - echo ${cc} ${cc.man or ""} ${binutils_bin} ${libc_bin} > $out/nix-support/propagated-user-env-packages + echo ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs '' -- cgit 1.4.1 From 0f0383394d006ae1c67e2815d5b4a8e4c7788de0 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 22 May 2017 20:59:39 -0400 Subject: cc-wrapper: Salt environment variables with LLVM triples We now (on cross) require per-target flag interposition by putting the triple in the names of the relevant environment variables, e.g: export NIX_arm_unknown_linux_gnu_CFLAGS_COMPILE=... The wrapper also has a `infixSalt` attribute (and "_" prefixed and suffixed variants) to assist downstream packages. Note how that the dashes are replaced to keep the identifier valid. Using names like this allows us to keep the settings for different compilers seperate. I think it might be even better to use names like `NIX_{BUILD,HOST}...` using the platform's role rather than the platform itself, but this would be more work as the previous stages' tools would have to be re- wrapped to take on their new role. I therefore didn't do this for now, but that route should be thoroughly explored in the future. --- pkgs/build-support/cc-wrapper/default.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 86314c5130fb..ffb1fdc139df 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -45,6 +45,12 @@ let default_cxx_stdlib_compile=optionalString (targetPlatform.isLinux && !(cc.isGNU or false)) "-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)"; + + dashlessTarget = stdenv.lib.replaceStrings ["-"] ["_"] targetPlatform.config; + # TODO(@Ericson2314) Make unconditional + infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) dashlessTarget; + infixSalt_ = stdenv.lib.optionalString (targetPlatform != hostPlatform) (dashlessTarget + "_"); + _infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) ("_" + dashlessTarget); in stdenv.mkDerivation { @@ -60,17 +66,17 @@ stdenv.mkDerivation { passthru = { inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile - prefix; + prefix infixSalt infixSalt_ _infixSalt; emacsBufferSetup = pkgs: '' ; We should handle propagation here too (mapc (lambda (arg) (when (file-directory-p (concat arg "/include")) - (setenv "NIX_CFLAGS_COMPILE" (concat (getenv "NIX_CFLAGS_COMPILE") " -isystem " arg "/include"))) + (setenv "NIX_${infixSalt_}CFLAGS_COMPILE" (concat (getenv "NIX_${infixSalt_}CFLAGS_COMPILE") " -isystem " arg "/include"))) (when (file-directory-p (concat arg "/lib")) - (setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib"))) + (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib"))) (when (file-directory-p (concat arg "/lib64")) - (setenv "NIX_LDFLAGS" (concat (getenv "NIX_LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) + (setenv "NIX_${infixSalt_}LDFLAGS" (concat (getenv "NIX_${infixSalt_}LDFLAGS") " -L" arg "/lib64")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)})) ''; }; -- cgit 1.4.1 From 8a7433fca4d08ee6654df498e0f238f0dfab01be Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 22 May 2017 21:00:21 -0400 Subject: cc-wrapper: Temporarily got to great lengths to avoid mass-rebuild Eventually we should avoid this "pre-wrapping" and just update those files in nixpkgs. This mass-rebuild change is best done along with those needed to reduce the disparity between native and cross (i.e. making native the "identity cross"). --- pkgs/build-support/cc-wrapper/default.nix | 75 ++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index ffb1fdc139df..77c0cfd63a7c 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -11,6 +11,7 @@ , dyld ? null # TODO: should this be a setup-hook on dyld? , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , hostPlatform, targetPlatform +, runCommand ? null }: with stdenv.lib; @@ -21,6 +22,8 @@ assert !nativeTools -> assert !(nativeLibc && noLibc); assert (noLibc || nativeLibc) == (libc == null); +assert targetPlatform != hostPlatform -> runCommand != null; + # For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. assert cc.langVhdl or false -> zlib != null; @@ -51,6 +54,38 @@ let infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) dashlessTarget; infixSalt_ = stdenv.lib.optionalString (targetPlatform != hostPlatform) (dashlessTarget + "_"); _infixSalt = stdenv.lib.optionalString (targetPlatform != hostPlatform) ("_" + dashlessTarget); + + # We want to prefix all NIX_ flags with the target triple + preWrap = textFile: + # TODO: Do even when not cross on next mass-rebuild + # TODO: use @target_tripple@ for consistency + if targetPlatform == hostPlatform + then textFile + else runCommand "sed-nix-env-vars" {} '' + cp ${textFile} $out + + sed -i $out \ + -e 's^NIX_^NIX_${infixSalt_}^g' \ + -e 's^addCVars^addCVars${_infixSalt}^g' \ + -e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g' + + # NIX_ things which we don't both use and define, we revert them + #asymmetric=$( + # for pre in "" "\\$" + # do + # grep -E -ho $pre'NIX_[a-zA-Z_]*' ./* | sed 's/\$//' | sort | uniq + # done | sort | uniq -c | sort -nr | sed -n 's/^1 NIX_//gp') + + # hard-code for now + asymmetric=("CXXSTDLIB_COMPILE" "CC") + + # The ([^a-zA-Z_]|$) bussiness is to ensure environment variables that + # begin with `NIX_CC` don't also get blacklisted. + for var in "''${asymmetric[@]}" + do + sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g" + done + ''; in stdenv.mkDerivation { @@ -185,7 +220,7 @@ stdenv.mkDerivation { # Solaris needs an additional ld wrapper. ldPath="${nativePrefix}/bin" exec="$ldPath/${prefix}ld" - wrap ld-solaris ${./ld-solaris-wrapper.sh} + wrap ld-solaris ${preWrap ./ld-solaris-wrapper.sh} '') + '' @@ -196,14 +231,14 @@ stdenv.mkDerivation { ln -s $ldPath/${prefix}as $out/bin/${prefix}as fi - wrap ${prefix}ld ${./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld} + wrap ${prefix}ld ${preWrap ./ld-wrapper.sh} ''${ld:-$ldPath/${prefix}ld} if [ -e ${binutils_bin}/bin/${prefix}ld.gold ]; then - wrap ${prefix}ld.gold ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold + wrap ${prefix}ld.gold ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.gold fi if [ -e ${binutils_bin}/bin/ld.bfd ]; then - wrap ${prefix}ld.bfd ${./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd + wrap ${prefix}ld.bfd ${preWrap ./ld-wrapper.sh} ${binutils_bin}/bin/${prefix}ld.bfd fi export real_cc=${prefix}cc @@ -211,49 +246,49 @@ stdenv.mkDerivation { export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}" if [ -e $ccPath/${prefix}gcc ]; then - wrap ${prefix}gcc ${./cc-wrapper.sh} $ccPath/${prefix}gcc + wrap ${prefix}gcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcc ln -s ${prefix}gcc $out/bin/${prefix}cc export real_cc=${prefix}gcc export real_cxx=${prefix}g++ elif [ -e $ccPath/clang ]; then - wrap ${prefix}clang ${./cc-wrapper.sh} $ccPath/clang + wrap ${prefix}clang ${preWrap ./cc-wrapper.sh} $ccPath/clang ln -s ${prefix}clang $out/bin/${prefix}cc export real_cc=clang export real_cxx=clang++ fi if [ -e $ccPath/${prefix}g++ ]; then - wrap ${prefix}g++ ${./cc-wrapper.sh} $ccPath/${prefix}g++ + wrap ${prefix}g++ ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}g++ ln -s ${prefix}g++ $out/bin/${prefix}c++ elif [ -e $ccPath/clang++ ]; then - wrap ${prefix}clang++ ${./cc-wrapper.sh} $ccPath/clang++ + wrap ${prefix}clang++ ${preWrap ./cc-wrapper.sh} $ccPath/clang++ ln -s ${prefix}clang++ $out/bin/${prefix}c++ fi if [ -e $ccPath/cpp ]; then - wrap ${prefix}cpp ${./cc-wrapper.sh} $ccPath/cpp + wrap ${prefix}cpp ${preWrap ./cc-wrapper.sh} $ccPath/cpp fi '' + optionalString cc.langFortran or false '' - wrap ${prefix}gfortran ${./cc-wrapper.sh} $ccPath/${prefix}gfortran + wrap ${prefix}gfortran ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gfortran ln -sv ${prefix}gfortran $out/bin/${prefix}g77 ln -sv ${prefix}gfortran $out/bin/${prefix}f77 '' + optionalString cc.langJava or false '' - wrap ${prefix}gcj ${./cc-wrapper.sh} $ccPath/${prefix}gcj + wrap ${prefix}gcj ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gcj '' + optionalString cc.langGo or false '' - wrap ${prefix}gccgo ${./cc-wrapper.sh} $ccPath/${prefix}gccgo + wrap ${prefix}gccgo ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gccgo '' + optionalString cc.langAda or false '' - wrap ${prefix}gnatgcc ${./cc-wrapper.sh} $ccPath/${prefix}gnatgcc - wrap ${prefix}gnatmake ${./gnat-wrapper.sh} $ccPath/${prefix}gnatmake - wrap ${prefix}gnatbind ${./gnat-wrapper.sh} $ccPath/${prefix}gnatbind - wrap ${prefix}gnatlink ${./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink + wrap ${prefix}gnatgcc ${preWrap ./cc-wrapper.sh} $ccPath/${prefix}gnatgcc + wrap ${prefix}gnatmake ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatmake + wrap ${prefix}gnatbind ${preWrap ./gnat-wrapper.sh} $ccPath/${prefix}gnatbind + wrap ${prefix}gnatlink ${preWrap ./gnatlink-wrapper.sh} $ccPath/${prefix}gnatlink '' + optionalString cc.langVhdl or false '' @@ -261,7 +296,7 @@ stdenv.mkDerivation { '' + '' - substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook.tmp + substituteAll ${preWrap ./setup-hook.sh} $out/nix-support/setup-hook.tmp cat $out/nix-support/setup-hook.tmp >> $out/nix-support/setup-hook rm $out/nix-support/setup-hook.tmp @@ -274,9 +309,9 @@ stdenv.mkDerivation { hardening_unsupported_flags+=" relro" fi - substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh - substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh - cp -p ${./utils.sh} $out/nix-support/utils.sh + substituteAll ${preWrap ./add-flags.sh} $out/nix-support/add-flags.sh + substituteAll ${preWrap ./add-hardening.sh} $out/nix-support/add-hardening.sh + cp -p ${preWrap ./utils.sh} $out/nix-support/utils.sh '' + extraBuildCommands; -- cgit 1.4.1 From 121e7d9335187fa742abba7994e03b495b8f2a6c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 26 Apr 2017 00:06:11 -0400 Subject: gcc-cross-wrapper: Remove in favor of newly-cross-supporting `cc-wrapper` --- pkgs/build-support/gcc-cross-wrapper/add-flags | 5 - pkgs/build-support/gcc-cross-wrapper/builder.sh | 120 ----------------- pkgs/build-support/gcc-cross-wrapper/default.nix | 65 --------- .../build-support/gcc-cross-wrapper/gcc-wrapper.sh | 117 ----------------- pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh | 145 --------------------- pkgs/build-support/gcc-cross-wrapper/setup-hook.sh | 90 ------------- pkgs/build-support/gcc-cross-wrapper/utils.sh | 24 ---- pkgs/top-level/all-packages.nix | 28 ++-- 8 files changed, 15 insertions(+), 579 deletions(-) delete mode 100644 pkgs/build-support/gcc-cross-wrapper/add-flags delete mode 100644 pkgs/build-support/gcc-cross-wrapper/builder.sh delete mode 100644 pkgs/build-support/gcc-cross-wrapper/default.nix delete mode 100644 pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh delete mode 100644 pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh delete mode 100644 pkgs/build-support/gcc-cross-wrapper/setup-hook.sh delete mode 100644 pkgs/build-support/gcc-cross-wrapper/utils.sh diff --git a/pkgs/build-support/gcc-cross-wrapper/add-flags b/pkgs/build-support/gcc-cross-wrapper/add-flags deleted file mode 100644 index 9ff4522e800b..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/add-flags +++ /dev/null @@ -1,5 +0,0 @@ -export NIX_CROSS_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CROSS_CFLAGS_COMPILE" -export NIX_CROSS_CFLAGS_LINK="@cflagsLink@ $NIX_CROSS_CFLAGS_LINK" -export NIX_CROSS_LDFLAGS="@ldflags@ $NIX_CROSS_LDFLAGS" -export NIX_CROSS_LDFLAGS_BEFORE="@ldflagsBefore@ $NIX_CROSS_LDFLAGS_BEFORE" -export NIX_CROSS_GLIBC_FLAGS_SET=1 diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh deleted file mode 100644 index b729144b8601..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/builder.sh +++ /dev/null @@ -1,120 +0,0 @@ -source $stdenv/setup - -mkdir $out -mkdir $out/bin -mkdir $out/nix-support - -# Force gcc to use ld-wrapper.sh when calling ld. -cflagsCompile="-B$out/bin/" - -if test -z "$nativeLibc" -a -n "$libc"; then - cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc_dev/include" - ldflags="$ldflags -L$libc/lib" - # Get the proper dynamic linker for glibc and uclibc. - dlinker=`eval 'echo $libc/lib/ld*.so.?'` - if [ -n "$dlinker" ]; then - ldflagsBefore="-dynamic-linker $dlinker" - - # The same as above, but put into files, useful for the gcc builder. - echo $dlinker > $out/nix-support/dynamic-linker - # This trick is to avoid dependencies on the cross-toolchain gcc - # for libgcc, libstdc++, ... - # -L is for libtool's .la files, and -rpath for the usual fixupPhase - # shrinking rpaths. - if [ -n "$gccLibs" ]; then - ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib" - fi - fi - - if [ -n "$osxMinVersion" ]; then - cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion" - fi - - echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - - echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags - - # The dynamic linker is passed in `ldflagsBefore' to allow - # explicit overrides of the dynamic linker by callers to gcc/ld - # (the *last* value counts, so ours should come first). - echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before -fi - -if test -n "$nativeTools"; then - gccPath="$nativePrefix/bin" - ldPath="$nativePrefix/bin" -else - ldflags="$ldflags -L$gcc/lib -L$gcc/lib64" - gccPath="$gcc/bin" - ldPath="$binutils/$crossConfig/bin" -fi - - -doSubstitute() { - local src=$1 - local dst=$2 - substitute "$src" "$dst" \ - --subst-var "out" \ - --subst-var "shell" \ - --subst-var "gcc" \ - --subst-var "gccProg" \ - --subst-var "binutils" \ - --subst-var "libc" \ - --subst-var "cflagsCompile" \ - --subst-var "cflagsLink" \ - --subst-var "ldflags" \ - --subst-var "ldflagsBefore" \ - --subst-var "ldPath" \ - --subst-var-by "ld" "$ldPath/ld" -} - - -# Make wrapper scripts around gcc, g++, and g77. Also make symlinks -# cc, c++, and f77. -mkGccWrapper() { - local dst=$1 - local src=$2 - - if ! test -f "$src"; then - echo "$src does not exist (skipping)" - return - fi - - gccProg="$src" - doSubstitute "$gccWrapper" "$dst" - chmod +x "$dst" -} - -mkGccWrapper $out/bin/$crossConfig-gcc $gccPath/$crossConfig-gcc -#ln -s gcc $out/bin/cc - -mkGccWrapper $out/bin/$crossConfig-g++ $gccPath/$crossConfig-g++ -ln -s $crossConfig-g++ $out/bin/$crossConfig-c++ - -mkGccWrapper $out/bin/$crossConfig-cpp $gccPath/$crossConfig-cpp - -mkGccWrapper $out/bin/$crossConfig-g77 $gccPath/$crossConfig-g77 -ln -s $crossConfig-g77 $out/bin/$crossConfig-f77 - -ln -s $binutils/bin/$crossConfig-ar $out/bin/$crossConfig-ar -ln -s $binutils/bin/$crossConfig-as $out/bin/$crossConfig-as -ln -s $binutils/bin/$crossConfig-nm $out/bin/$crossConfig-nm -ln -s $binutils/bin/$crossConfig-strip $out/bin/$crossConfig-strip - - -# Make a wrapper around the linker. -doSubstitute "$ldWrapper" "$out/bin/$crossConfig-ld" -chmod +x "$out/bin/$crossConfig-ld" - - -# Emit a setup hook. Also store the path to the original GCC and -# Glibc. -test -n "$gcc" && echo $gcc > $out/nix-support/orig-cc -test -n "$libc" && echo $libc > $out/nix-support/orig-libc -test -n "$libc_dev" && echo $libc_dev > $out/nix-support/orig-libc-dev - -doSubstitute "$addFlags" "$out/nix-support/add-flags" - -doSubstitute "$setupHook" "$out/nix-support/setup-hook" - -cp -p $utils $out/nix-support/utils diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix deleted file mode 100644 index 505d80a6b2ac..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/default.nix +++ /dev/null @@ -1,65 +0,0 @@ -# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't -# know where the C library and standard header files are. Therefore -# the compiler produced by that package cannot be installed directly -# in a user environment and used from the command line. This -# stdenv.mkDerivation provides a wrapper that sets up the right environment -# variables so that the compiler and the linker just "work". - -{ name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? "" -, gcc ? null, libc ? null, binutils ? null, shell ? "", cross -}: - -assert nativeTools -> nativePrefix != ""; -assert !nativeTools -> gcc != null && binutils != null; -assert !noLibc -> (!nativeLibc -> libc != null); - -let - chosenName = if name == "" then gcc.name else name; - gccLibs = stdenv.mkDerivation { - name = chosenName + "-libs"; - phases = [ "installPhase" ]; - installPhase = '' - echo $out - mkdir -p "$out" - - if [ -d "${gcc}/${cross.config}/lib" ] - then - cp -Rd "${gcc}/${cross.config}/lib" "$out/lib" - chmod -R +w "$out/lib" - for a in "$out/lib/"*.la; do - sed -i -e "s,${gcc}/${cross.config}/lib,$out/lib,g" $a - done - rm -f "$out/lib/"*.py - else - # The MinGW cross-compiler falls into this category. - mkdir "$out/lib" - fi - ''; - }; -in -stdenv.mkDerivation { - builder = ./builder.sh; - setupHook = ./setup-hook.sh; - gccWrapper = ./gcc-wrapper.sh; - ldWrapper = ./ld-wrapper.sh; - utils = ./utils.sh; - addFlags = ./add-flags; - inherit nativeTools nativeLibc nativePrefix gcc binutils; - libc = if libc ? out then libc.out else libc; - libc_dev = if libc ? dev then libc.dev else libc; - crossConfig = if cross != null then cross.config else null; - osxMinVersion = cross.osxMinVersion or null; - gccLibs = if gcc != null then gccLibs else null; - name = chosenName; - langC = if nativeTools then true else gcc.langC; - langCC = if nativeTools then true else gcc.langCC; - langF77 = if nativeTools then false else gcc ? langFortran; - shell = if shell == "" then stdenv.shell else shell; - meta = if gcc != null then gcc.meta else - { description = "System C compiler wrapper"; - }; - - passthru = { - target = cross; - }; -} diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh deleted file mode 100644 index c15777144e11..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh +++ /dev/null @@ -1,117 +0,0 @@ -#! @shell@ -e - -if test -n "$NIX_CC_WRAPPER_START_HOOK"; then - source "$NIX_CC_WRAPPER_START_HOOK" -fi - -if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then - source @out@/nix-support/add-flags -fi - -source @out@/nix-support/utils - - -# Figure out if linker flags should be passed. GCC prints annoying -# warnings when they are not needed. -dontLink=0 -if test "$*" = "-v" -o -z "$*"; then - dontLink=1 -else - for i in "$@"; do - if test "$i" = "-c"; then - dontLink=1 - elif test "$i" = "-S"; then - dontLink=1 - elif test "$i" = "-E"; then - dontLink=1 - elif test "$i" = "-E"; then - dontLink=1 - elif test "$i" = "-M"; then - dontLink=1 - elif test "$i" = "-MM"; then - dontLink=1 - fi - done -fi - - -# Optionally filter out paths not refering to the store. -params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then - rest=() - n=0 - while test $n -lt ${#params[*]}; do - p=${params[n]} - p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then - skip $p - elif test "$p" = "-L" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then - skip $p - elif test "$p" = "-I" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "$p" = "-isystem" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") -fi - - -# Add the flags for the C compiler proper. -extraAfter=($NIX_CROSS_CFLAGS_COMPILE) -extraBefore=() - -if test "$dontLink" != "1"; then - - # Add the flags that should only be passed to the compiler when - # linking. - extraAfter=(${extraAfter[@]} $NIX_CROSS_CFLAGS_LINK) - - # Add the flags that should be passed to the linker (and prevent - # `ld-wrapper' from adding NIX_CROSS_LDFLAGS again). - for i in $NIX_CROSS_LDFLAGS_BEFORE; do - if test "${i:0:3}" = "-L/"; then - extraBefore=(${extraBefore[@]} "$i") - else - extraBefore=(${extraBefore[@]} "-Wl,$i") - fi - done - for i in $NIX_CROSS_LDFLAGS; do - if test "${i:0:3}" = "-L/"; then - extraAfter=(${extraAfter[@]} "$i") - else - extraAfter=(${extraAfter[@]} "-Wl,$i") - fi - done - export NIX_CROSS_LDFLAGS_SET=1 -fi - -# Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then - echo "original flags to @gccProg@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extraBefore flags to @gccProg@:" >&2 - for i in ${extraBefore[@]}; do - echo " $i" >&2 - done - echo "extraAfter flags to @gccProg@:" >&2 - for i in ${extraAfter[@]}; do - echo " $i" >&2 - done -fi - -if test -n "$NIX_CC_WRAPPER_EXEC_HOOK"; then - source "$NIX_CC_WRAPPER_EXEC_HOOK" -fi - -# We want gcc to call the wrapper linker, not that of binutils. -export PATH="@ldPath@:$PATH" - -exec @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh deleted file mode 100644 index 226fad833599..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh +++ /dev/null @@ -1,145 +0,0 @@ -#! @shell@ -e - -if test -n "$NIX_LD_WRAPPER_START_HOOK"; then - source "$NIX_LD_WRAPPER_START_HOOK" -fi - -if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then - source @out@/nix-support/add-flags -fi - -source @out@/nix-support/utils - - -# Optionally filter out paths not refering to the store. -params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \ - -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_CROSS_LDFLAGS_SET" \); then - rest=() - n=0 - while test $n -lt ${#params[*]}; do - p=${params[n]} - p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then - skip $p - elif test "$p" = "-L" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "$p" = "-rpath" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "$p" = "-dynamic-linker" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "${p:0:1}" = "/" && badPath "$p"; then - # We cannot skip this; barf. - echo "impure path \`$p' used in link" >&2 - exit 1 - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") -fi - - -extra=() -extraBefore=() - -if test -z "$NIX_CROSS_LDFLAGS_SET"; then - extra=(${extra[@]} $NIX_CROSS_LDFLAGS) - extraBefore=(${extraBefore[@]} $NIX_CROSS_LDFLAGS_BEFORE) -fi - - -# Add all used dynamic libraries to the rpath. -if test "$NIX_DONT_SET_RPATH" != "1"; then - - # First, find all -L... switches. - allParams=("${params[@]}" ${extra[@]}) - libPath="" - addToLibPath() { - local path="$1" - if test "${path:0:1}" != "/"; then return 0; fi - case "$path" in - *..*|*./*|*/.*|*//*) - local path2 - if path2=$(readlink -f "$path"); then - path="$path2" - fi - ;; - esac - case $libPath in - *\ $path\ *) return 0 ;; - esac - libPath="$libPath $path " - } - n=0 - while test $n -lt ${#allParams[*]}; do - p=${allParams[n]} - p2=${allParams[$((n+1))]} - if test "${p:0:3}" = "-L/"; then - addToLibPath ${p:2} - elif test "$p" = "-L"; then - addToLibPath ${p2} - n=$((n + 1)) - fi - n=$((n + 1)) - done - - # Second, for each -l... switch, find the directory containing the - # library and add it to the rpath. - rpath="" - addToRPath() { - # If the path is not in the store, don't add it to the rpath. - # This typically happens for libraries in /tmp that are later - # copied to $out/lib. If not, we're screwed. - if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi - case $rpath in - *\ $1\ *) return 0 ;; - esac - rpath="$rpath $1 " - } - findLib() { - for i in $libPath; do - if test -f $i/lib$1.so; then - addToRPath $i - fi - done - } - n=0 - while test $n -lt ${#allParams[*]}; do - p=${allParams[n]} - p2=${allParams[$((n+1))]} - if test "${p:0:2}" = "-l"; then - findLib ${p:2} - elif test "$p" = "-l"; then - # I haven't seen `-l foo', but you never know... - findLib ${p2} - n=$((n + 1)) - fi - n=$((n + 1)) - done - - # Finally, add `-rpath' switches. - for i in $rpath; do - extra=(${extra[@]} -rpath $i -rpath-link $i) - done -fi - - -# Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then - echo "original flags to @ld@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extra flags to @ld@:" >&2 - for i in ${extra[@]}; do - echo " $i" >&2 - done -fi - -if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then - source "$NIX_LD_WRAPPER_EXEC_HOOK" -fi - -exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]} diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh deleted file mode 100644 index 599954bd127d..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh +++ /dev/null @@ -1,90 +0,0 @@ -NIX_CROSS_CFLAGS_COMPILE="" -NIX_CROSS_LDFLAGS="" - -crossAddCVars () { - if test -d $1/include; then - export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include" - fi - - if test -d $1/lib; then - export NIX_CROSS_LDFLAGS="$NIX_CROSS_LDFLAGS -L$1/lib -rpath-link $1/lib" - fi -} - -crossEnvHooks+=(crossAddCVars) - -crossStripDirs() { - local dirs="$1" - local stripFlags="$2" - local dirsNew= - - for d in ${dirs}; do - if test -d "$prefix/$d"; then - dirsNew="${dirsNew} $prefix/$d " - fi - done - dirs=${dirsNew} - - if test -n "${dirs}"; then - header "cross stripping (with flags $stripFlags) in $dirs" - # libc_nonshared.a should never be stripped, or builds will break. - find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true - stopNest - fi -} - -crossStrip () { - # In cross_renaming we may rename dontCrossStrip to dontStrip, and - # dontStrip to dontNativeStrip. - # TODO: strip _only_ ELF executables, and return || fail here... - if test -z "$dontCrossStrip"; then - stripDebugList=${stripDebugList:-lib lib64 libexec bin sbin} - if test -n "$stripDebugList"; then - crossStripDirs "$stripDebugList" "${stripDebugFlags:--S}" - fi - - stripAllList=${stripAllList:-} - if test -n "$stripAllList"; then - crossStripDirs "$stripAllList" "${stripAllFlags:--s}" - fi - fi -} - -preDistPhases=(${preDistPhases[@]} crossStrip) - - -# Note: these come *after* $out in the PATH (see setup.sh). - -if test -n "@gcc@"; then - PATH=$PATH:@gcc@/bin -fi - -if test -n "@binutils@"; then - PATH=$PATH:@binutils@/bin -fi - -if test -n "@libc@"; then - PATH=$PATH:@libc@/bin - crossAddCVars @libc@ -fi - -if test "$dontSetConfigureCross" != "1"; then - configureFlags="$configureFlags --build=$system --host=$crossConfig" -fi -# Disabling the tests when cross compiling, as usually the tests are meant for -# native compilations. -doCheck="" - -# Don't strip foreign binaries with native "strip" tool. -dontStrip=1 - -# Add the output as an rpath. -if test "$NIX_NO_SELF_RPATH" != "1"; then - export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS" - if test -n "$NIX_LIB64_IN_SELF_RPATH"; then - export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS" - fi -fi - -export CC=${crossConfig}-gcc -export CXX=${crossConfig}-g++ diff --git a/pkgs/build-support/gcc-cross-wrapper/utils.sh b/pkgs/build-support/gcc-cross-wrapper/utils.sh deleted file mode 100644 index 753b3772e956..000000000000 --- a/pkgs/build-support/gcc-cross-wrapper/utils.sh +++ /dev/null @@ -1,24 +0,0 @@ -skip () { - if test "$NIX_DEBUG" = "1"; then - echo "skipping impure path $1" >&2 - fi -} - - -# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but -# `/nix/store/.../lib/foo.so' isn't. -badPath() { - local p=$1 - - # Relative paths are okay (since they're presumably relative to - # the temporary build directory). - if test "${p:0:1}" != "/"; then return 1; fi - - # Otherwise, the path should refer to the store or some temporary - # directory (including the build directory). - test \ - "$p" != "/dev/null" -a \ - "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ - "${p:0:4}" != "/tmp" -a \ - "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f2fc65da558d..11afb0d1e313 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5168,8 +5168,8 @@ with pkgs; if targetPlatform.libc == "msvcrt" then windows.mingw_w64_headers else if targetPlatform.libc == "libSystem" then darwin.xcode else null; - in wrapGCCCross { - gcc = forcedNativePackages.gcc.cc.override { + in wrapCCCross { + cc = forcedNativePackages.gcc.cc.override { crossStageStatic = true; langCC = false; libcCross = libcCross1; @@ -5179,19 +5179,17 @@ with pkgs; }; libc = libcCross1; inherit (forcedNativePackages) binutils; - cross = targetPlatform; }; # Only needed for mingw builds - gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapGCCCross { - gcc = gccCrossStageStatic.gcc; + gccCrossMingw2 = assert targetPlatform != buildPlatform; wrapCCCross { + cc = gccCrossStageStatic.gcc; libc = windows.mingw_headers2; inherit (forcedNativePackages) binutils; - cross = targetPlatform; }; - gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapGCCCross { - gcc = forcedNativePackages.gcc.cc.override { + gccCrossStageFinal = assert targetPlatform != buildPlatform; wrapCCCross { + cc = forcedNativePackages.gcc.cc.override { crossStageStatic = false; # Why is this needed? @@ -5199,7 +5197,6 @@ with pkgs; }; libc = libcCross; inherit (forcedNativePackages) binutils; - cross = targetPlatform; }; gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 { @@ -5924,14 +5921,19 @@ with pkgs; libc = glibc; }; - wrapGCCCross = - {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: + wrapCCCross = + {cc, libc, binutils, shell ? "", name ? "gcc-cross-wrapper"}: - forcedNativePackages.callPackage ../build-support/gcc-cross-wrapper { + forcedNativePackages.ccWrapperFun { nativeTools = false; nativeLibc = false; noLibc = (libc == null); - inherit gcc binutils libc shell name cross; + + dyld = if stdenv.isDarwin then darwin.dyld else null; + isGNU = cc.isGNU or false; + isClang = cc.isClang or false; + + inherit cc binutils libc shell name; }; # prolog -- cgit 1.4.1 From 9bfd03eff78aa37bff9a7f4cb12c6bed1f04e764 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 26 Apr 2017 00:06:11 -0400 Subject: cross stdenv adaptor: Remove `ccCross` `binutils` attrs and binutils extra buildDepends It now has the correct wrapped tools and nothing else is needed. --- pkgs/stdenv/adapters.nix | 18 +++++++++--------- pkgs/stdenv/cross/default.nix | 15 ++++++--------- pkgs/stdenv/linux/make-bootstrap-tools-cross.nix | 1 - pkgs/top-level/all-packages.nix | 1 - 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 7eab7ddb072c..fc332dff3aa3 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -56,12 +56,17 @@ rec { # Return a modified stdenv that adds a cross compiler to the # builds. - makeStdenvCross = stdenv: cross: binutils: gccCross: stdenv // { + makeStdenvCross = stdenvOrig: cross: cc: let + stdenv = stdenvOrig.override { + inherit cc; - # Overrides are surely not valid as packages built with this run on a - # different platform. - overrides = _: _: {}; + allowedRequisites = null; + # Overrides are surely not valid as packages built with this run on a + # different platform. + overrides = _: _: {}; + }; + in stdenv // { mkDerivation = { name ? "", buildInputs ? [], nativeBuildInputs ? [] , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [] @@ -91,7 +96,6 @@ rec { name = name + "-" + cross.config; nativeBuildInputs = nativeBuildInputs ++ nativeInputsFromBuildInputs - ++ [ gccCross binutils ] ++ stdenv.lib.optional selfNativeBuildInput nativeDrv # without proper `file` command, libtool sometimes fails # to recognize 64-bit DLLs @@ -109,10 +113,6 @@ rec { crossConfig = cross.config; } // args.crossAttrs or {}); - - inherit gccCross binutils; - ccCross = gccCross; - }; diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 7fe567251708..f9c23078cd30 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -31,15 +31,12 @@ in bootStages ++ [ targetPlatform = crossSystem; inherit config overlays; selfBuild = false; - stdenv = if crossSystem.useiOSCross or false - then let - inherit (buildPackages.darwin.ios-cross) cc binutils; - in buildPackages.makeStdenvCross - buildPackages.stdenv crossSystem - binutils cc - else buildPackages.makeStdenvCross - buildPackages.stdenv crossSystem - buildPackages.binutils buildPackages.gccCrossStageFinal; + stdenv = buildPackages.makeStdenvCross + buildPackages.stdenv + crossSystem + (if crossSystem.useiOSCross or false + then buildPackages.darwin.ios-cross + else buildPackages.gccCrossStageFinal); }) ] diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index 0378891b27ab..90c9d2cef67f 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -81,7 +81,6 @@ rec { nativeBuildInputs = [ pkgs.buildPackages.nukeReferences pkgs.buildPackages.cpio - pkgs.buildPackages.binutils ]; buildCommand = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 11afb0d1e313..b499b623a8c2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7805,7 +7805,6 @@ with pkgs; stdenv = buildPackages.makeStdenvCross buildPackages.buildPackages.stdenv buildPackages.targetPlatform - buildPackages.binutils buildPackages.gccCrossStageStatic; }; -- cgit 1.4.1 From 594d26420594acf458e5a8ab75229a2147d9194f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 26 Apr 2017 00:06:11 -0400 Subject: cross stdenv adaptor: Support --host --build --target across the board Packages get --host and --target by default, but can explicitly request any subset to be passed as needed. See docs for more info. rustc: Avoid hash breakage by using the old (ignored) dontSetConfigureCross when not cross building --- doc/stdenv.xml | 10 +++++++ pkgs/applications/video/mplayer/default.nix | 6 ++-- pkgs/applications/video/omxplayer/default.nix | 2 +- pkgs/development/compilers/ghc/head.nix | 2 +- pkgs/development/compilers/rust/rustc.nix | 4 ++- pkgs/development/libraries/ffmpeg-full/default.nix | 2 +- pkgs/development/libraries/ffmpeg/generic.nix | 2 +- pkgs/development/libraries/libav/default.nix | 2 +- pkgs/development/libraries/libvpx/default.nix | 2 +- pkgs/development/libraries/libvpx/git.nix | 2 +- pkgs/development/libraries/qt-4.x/4.8/default.nix | 2 +- pkgs/development/libraries/zlib/default.nix | 2 +- pkgs/stdenv/adapters.nix | 33 +++++++++++++++++----- pkgs/stdenv/cross/default.nix | 15 ++++++---- pkgs/top-level/all-packages.nix | 9 +++--- 15 files changed, 66 insertions(+), 29 deletions(-) diff --git a/doc/stdenv.xml b/doc/stdenv.xml index 9ec14d5a7828..e637962fbb7d 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -640,6 +640,16 @@ script) if it exists. true. + + configurePlatforms + + By default, when cross compiling, the configure script has and passed. + Packages can instead pass [ "build" "host" "target" ] or a subset to control exactly which platform flags are passed. + Compilers and other tools should use this to also pass the target platform, for example. + Note eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity. + + + preConfigure Hook executed at the start of the configure diff --git a/pkgs/applications/video/mplayer/default.nix b/pkgs/applications/video/mplayer/default.nix index 37b424d922ba..9ae1b99f86fd 100644 --- a/pkgs/applications/video/mplayer/default.nix +++ b/pkgs/applications/video/mplayer/default.nix @@ -25,6 +25,7 @@ , libjpegSupport ? true, libjpeg ? null , useUnfreeCodecs ? false , darwin ? null +, hostPlatform }: assert fontconfigSupport -> (fontconfig != null); @@ -185,13 +186,14 @@ stdenv.mkDerivation rec { ''; crossAttrs = { - dontSetConfigureCross = true; + configurePlatforms = []; # Some things (vidix) are nanonote specific. Once someone cares, we can make options from them. + # Note, the `target` vs `host` confusion is intensional. preConfigure = '' configureFlags="`echo $configureFlags | sed -e 's/--codecsdir[^ ]\+//' \ -e 's/--enable-runtime-cpudetection//' `" - configureFlags="$configureFlags --target=${stdenv.cross.arch}-linux + configureFlags="$configureFlags --target=${hostPlatform.arch}-linux --enable-cross-compile --cc=$crossConfig-gcc --as=$crossConfig-as --disable-vidix-pcidb --with-vidix-drivers=no --host-cc=gcc" ''; diff --git a/pkgs/applications/video/omxplayer/default.nix b/pkgs/applications/video/omxplayer/default.nix index 449190cfaa17..01a85f3d9528 100644 --- a/pkgs/applications/video/omxplayer/default.nix +++ b/pkgs/applications/video/omxplayer/default.nix @@ -44,7 +44,7 @@ let enableParallelBuilding = true; crossAttrs = { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ "--cross-prefix=${stdenv.cross.config}-" "--enable-cross-compile" diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 53069619ffb0..70200b2fa01b 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -114,7 +114,7 @@ in stdenv.mkDerivation (rec { buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ]; - dontSetConfigureCross = true; + configurePlatforms = []; passthru = { inherit bootPkgs cross; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 4e0d0971cb66..717c0092c946 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -10,6 +10,7 @@ , targetPatches , targetToolchains , doCheck ? true +, buildPlatform, hostPlatform } @ args: let @@ -137,7 +138,8 @@ stdenv.mkDerivation { inherit doCheck; - dontSetConfigureCross = true; + ${if buildPlatform == hostPlatform then "dontSetConfigureCross" else null} = true; + ${if buildPlatform != hostPlatform then "configurePlatforms" else null} = []; # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764 # https://github.com/rust-lang/rust/issues/30181 diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix index d5b2632a3716..3f847bc752f0 100644 --- a/pkgs/development/libraries/ffmpeg-full/default.nix +++ b/pkgs/development/libraries/ffmpeg-full/default.nix @@ -446,7 +446,7 @@ stdenv.mkDerivation rec { fi ''; in { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ "--cross-prefix=${stdenv.cross.config}-" "--enable-cross-compile" diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 57ac086368f4..762a4c9503fb 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -187,7 +187,7 @@ stdenv.mkDerivation rec { fi ''; in { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ "--cross-prefix=${stdenv.cross.config}-" "--enable-cross-compile" diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix index 6aa88a524c0e..785e3599bf17 100644 --- a/pkgs/development/libraries/libav/default.nix +++ b/pkgs/development/libraries/libav/default.nix @@ -105,7 +105,7 @@ let installCheckTarget = "check"; # tests need to be run *after* installation crossAttrs = { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ "--cross-prefix=${stdenv.cross.config}-" "--enable-cross-compile" diff --git a/pkgs/development/libraries/libvpx/default.nix b/pkgs/development/libraries/libvpx/default.nix index 7efff3412a39..09fc3a2a9da9 100644 --- a/pkgs/development/libraries/libvpx/default.nix +++ b/pkgs/development/libraries/libvpx/default.nix @@ -148,7 +148,7 @@ stdenv.mkDerivation rec { isCygwin = stdenv.cross.libc == "msvcrt"; isDarwin = stdenv.cross.libc == "libSystem"; in { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ #"--extra-cflags=" #"--extra-cxxflags=" diff --git a/pkgs/development/libraries/libvpx/git.nix b/pkgs/development/libraries/libvpx/git.nix index 1dafd4a124dc..ceda1c263893 100644 --- a/pkgs/development/libraries/libvpx/git.nix +++ b/pkgs/development/libraries/libvpx/git.nix @@ -156,7 +156,7 @@ stdenv.mkDerivation rec { isCygwin = stdenv.cross.libc == "msvcrt"; isDarwin = stdenv.cross.libc == "libSystem"; in { - dontSetConfigureCross = true; + configurePlatforms = []; configureFlags = configureFlags ++ [ #"--extra-cflags=" #"--prefix=" diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix index 18f2e7611a9e..dee83306cc6e 100644 --- a/pkgs/development/libraries/qt-4.x/4.8/default.nix +++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix @@ -209,7 +209,7 @@ stdenv.mkDerivation rec { postInstall = '' cp bin/qmake* $out/bin ''; - dontSetConfigureCross = true; + configurePlatforms = []; dontStrip = true; } // optionalAttrs isMingw { propagatedBuildInputs = [ ]; diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 5d96299380ed..dc6f0a455d86 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -53,7 +53,7 @@ stdenv.mkDerivation rec { crossAttrs = { dontStrip = static; - dontSetConfigureCross = true; + configurePlatforms = []; } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "msvcrt") { installFlags = [ "BINARY_PATH=$(out)/bin" diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index fc332dff3aa3..7fd283ca8230 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -56,8 +56,15 @@ rec { # Return a modified stdenv that adds a cross compiler to the # builds. - makeStdenvCross = stdenvOrig: cross: cc: let - stdenv = stdenvOrig.override { + makeStdenvCross = { stdenv + , cc + , buildPlatform, hostPlatform, targetPlatform + } @ overrideArgs: let + stdenv = overrideArgs.stdenv.override { + # TODO(@Ericson2314): Cannot do this for now because then Nix thinks the + # resulting derivation should be built on the host platform. + #hostPlatform = buildPlatform; + #targetPlatform = hostPlatform; inherit cc; allowedRequisites = null; @@ -70,7 +77,12 @@ rec { mkDerivation = { name ? "", buildInputs ? [], nativeBuildInputs ? [] , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [] - , selfNativeBuildInput ? false, ... + , configureFlags ? [] + , # Target is not included by default because most programs don't care. + # Including it then would cause needless massive rebuilds. + configurePlatforms ? args.crossAttrs.configurePlatforms or [ "build" "host" ] + , selfNativeBuildInput ? args.crossAttrs.selfNativeBuildInput or false + , ... } @ args: let @@ -93,16 +105,23 @@ rec { nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull; in stdenv.mkDerivation (args // { - name = name + "-" + cross.config; + name = name + "-" + hostPlatform.config; nativeBuildInputs = nativeBuildInputs ++ nativeInputsFromBuildInputs ++ stdenv.lib.optional selfNativeBuildInput nativeDrv # without proper `file` command, libtool sometimes fails # to recognize 64-bit DLLs - ++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file - ++ stdenv.lib.optional (cross.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook + ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file + ++ stdenv.lib.optional (hostPlatform.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook ; + # This parameter is sometimes a string and sometimes a list, yuck + configureFlags = let inherit (stdenv.lib) optional elem; in + (if stdenv.lib.isString configureFlags then [configureFlags] else configureFlags) + ++ optional (elem "build" configurePlatforms) "--build=${buildPlatform.config}" + ++ optional (elem "host" configurePlatforms) "--host=${hostPlatform.config}" + ++ optional (elem "target" configurePlatforms) "--target=${targetPlatform.config}"; + # Cross-linking dynamic libraries, every buildInput should # be propagated because ld needs the -rpath-link to find # any library needed to link the program dynamically at @@ -111,7 +130,7 @@ rec { propagatedBuildInputs = propagatedBuildInputs ++ buildInputs; propagatedNativeBuildInputs = propagatedNativeBuildInputs; - crossConfig = cross.config; + crossConfig = hostPlatform.config; } // args.crossAttrs or {}); }; diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index f9c23078cd30..125c4300975a 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -31,12 +31,15 @@ in bootStages ++ [ targetPlatform = crossSystem; inherit config overlays; selfBuild = false; - stdenv = buildPackages.makeStdenvCross - buildPackages.stdenv - crossSystem - (if crossSystem.useiOSCross or false - then buildPackages.darwin.ios-cross - else buildPackages.gccCrossStageFinal); + stdenv = buildPackages.makeStdenvCross { + inherit (buildPackages) stdenv; + buildPlatform = localSystem; + hostPlatform = crossSystem; + targetPlatform = crossSystem; + cc = if crossSystem.useiOSCross or false + then buildPackages.darwin.ios-cross + else buildPackages.gccCrossStageFinal; + }; }) ] diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b499b623a8c2..c201715dfef3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7802,10 +7802,11 @@ with pkgs; installLocales = config.glibc.locales or false; # Can't just overrideCC, because then the stdenv-cross mkDerivation will be # thrown away. TODO: find a better solution for this. - stdenv = buildPackages.makeStdenvCross - buildPackages.buildPackages.stdenv - buildPackages.targetPlatform - buildPackages.gccCrossStageStatic; + stdenv = buildPackages.makeStdenvCross { + inherit (buildPackages.buildPackages) stdenv; + inherit buildPlatform hostPlatform targetPlatform; + cc = buildPackages.gccCrossStageStatic; + }; }; # We can choose: -- cgit 1.4.1 From e0492d58a68a825924493d381bcc52a20177e5ef Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 13:32:15 -0400 Subject: cross stdenv adaptor: Disable checkPhase by default Before gcc-cross-wrapper did this unconditionally --- pkgs/stdenv/adapters.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 7fd283ca8230..7515a72fcfdf 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -77,6 +77,9 @@ rec { mkDerivation = { name ? "", buildInputs ? [], nativeBuildInputs ? [] , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [] + , # Disabling the tests by default when cross compiling, as usually the + # tests rely on being able to run produced binaries. + doCheck ? false , configureFlags ? [] , # Target is not included by default because most programs don't care. # Including it then would cause needless massive rebuilds. @@ -115,6 +118,8 @@ rec { ++ stdenv.lib.optional (hostPlatform.config == "aarch64-linux-gnu") pkgs.updateAutotoolsGnuConfigScriptsHook ; + inherit doCheck; + # This parameter is sometimes a string and sometimes a list, yuck configureFlags = let inherit (stdenv.lib) optional elem; in (if stdenv.lib.isString configureFlags then [configureFlags] else configureFlags) -- cgit 1.4.1 From c1fb71b74a15eba29c01ce8b2aa514310c437992 Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Tue, 30 May 2017 23:31:44 -0400 Subject: cc-wrapper: when cross building, wedge in setting AR, AS, and LD env vars to their cross building versions I think it's ok to export things which aren't wrapped. The cc-wrapper can be thought of as responsible for all of binutils and the c compiler, only wrapping those binaries which are necessary to interposition---as opposed to all binaries it thinks are relevaant. Conversely, adding the setup hook to the unwrapped compilers would be unforunate as hooks are ugly hacks and the compilers themselves take a long time to rebuild. Better to wholely separate "pure packages" from hacks. --- pkgs/build-support/cc-wrapper/default.nix | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 77c0cfd63a7c..83326777326d 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -61,14 +61,28 @@ let # TODO: use @target_tripple@ for consistency if targetPlatform == hostPlatform then textFile - else runCommand "sed-nix-env-vars" {} '' - cp ${textFile} $out + else runCommand "sed-nix-env-vars" {} ('' + cp --no-preserve=mode ${textFile} $out sed -i $out \ -e 's^NIX_^NIX_${infixSalt_}^g' \ -e 's^addCVars^addCVars${_infixSalt}^g' \ -e 's^\[ -z "\$crossConfig" \]^\[\[ "${builtins.toString (targetPlatform != hostPlatform)}" || -z "$crossConfig" \]\]^g' + '' + stdenv.lib.optionalString (textFile == ./setup-hook.sh) '' + cat << 'EOF' >> $out + for CMD in ar as nm objcopy ranlib strip strings size ld + do + # which is not part of stdenv, but compgen will do for now + if + PATH=$_PATH type -p ${prefix}$CMD > /dev/null + then + export ''$(echo "$CMD" | tr "[:lower:]" "[:upper:]")=${prefix}''${CMD}; + fi + done + EOF + '' + '' + # NIX_ things which we don't both use and define, we revert them #asymmetric=$( # for pre in "" "\\$" @@ -85,7 +99,7 @@ let do sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g" done - ''; + ''); in stdenv.mkDerivation { -- cgit 1.4.1 From 0aee847858631b2b5aaef54714b598ce78b31b20 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 2 Jun 2017 13:31:11 -0400 Subject: cc-wrapper: Make the cross compiler use a crossEnvHook This is a hack until stdenv's setup.hs gets overhauled --- pkgs/build-support/cc-wrapper/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 83326777326d..3a155b26319d 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -81,6 +81,8 @@ let fi done EOF + + sed -i $out -e 's_envHooks_crossEnvHooks_g' '' + '' # NIX_ things which we don't both use and define, we revert them -- cgit 1.4.1 From c2e2152afc513fa4eda51b96dc5c7f349c3497da Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 19 Jun 2017 11:10:27 -0400 Subject: cc-wrapper: Port over finding of dynamic linker from gcc-cross-wrapper At the next break, we can deduplicate and go for the best of both worlds. --- pkgs/build-support/cc-wrapper/default.nix | 60 ++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 3a155b26319d..35a5e90583b8 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -102,6 +102,24 @@ let sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g" done ''); + + # The dynamic linker has different names on different platforms. + dynamicLinker = + if !nativeLibc then + (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else + if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else + # ARM with a wildcard, which can be "" or "-armhf". + if targetPlatform.isArm32 then "ld-linux*.so.3" else + if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else + if targetPlatform.system == "powerpc-linux" then "ld.so.1" else + if targetPlatform.system == "mips64el-linux" then "ld.so.1" else + if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else + if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else + builtins.trace + "Don't know the name of the dynamic linker for platform ${targetPlatform.config}, so guessing instead." + null) + else ""; + in stdenv.mkDerivation { @@ -144,7 +162,12 @@ stdenv.mkDerivation { } '' - + optionalString (libc != null) (if (!targetPlatform.isDarwin) then '' + # TODO(@Ericson2314): Unify logic next hash break + + optionalString (libc != null) (if (targetPlatform.isDarwin) then '' + echo $dynamicLinker > $out/nix-support/dynamic-linker + + echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook + '' else if dynamicLinker != null then '' dynamicLinker="${libc_lib}/lib/$dynamicLinker" echo $dynamicLinker > $out/nix-support/dynamic-linker @@ -157,9 +180,21 @@ stdenv.mkDerivation { # (the *last* value counts, so ours should come first). echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before '' else '' - echo $dynamicLinker > $out/nix-support/dynamic-linker + dynamicLinker=`eval 'echo $libc/lib/ld*.so.?'` + if [ -n "$dynamicLinker" ]; then + echo $dynamicLinker > $out/nix-support/dynamic-linker - echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook + if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then + echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + fi + + ldflagsBefore="-dynamic-linker $dlinker" + fi + + # The dynamic linker is passed in `ldflagsBefore' to allow + # explicit overrides of the dynamic linker by callers to gcc/ld + # (the *last* value counts, so ours should come first). + echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before '') + optionalString (libc != null) '' @@ -331,24 +366,7 @@ stdenv.mkDerivation { '' + extraBuildCommands; - # The dynamic linker has different names on different Linux platforms. - # - # TODO(1b62c9c06173f4d5e6b090e5ae0c68fa5f478faf): This is not the best way to - # do this. I think the reference should be the style in the gcc-cross-wrapper, - # but to keep a stable stdenv now I do this sufficient if/else. - dynamicLinker = - if !nativeLibc then - (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else - if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else - # ARM with a wildcard, which can be "" or "-armhf". - if targetPlatform.isArm32 then "ld-linux*.so.3" else - if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else - if targetPlatform.system == "powerpc-linux" then "ld.so.1" else - if targetPlatform.system == "mips64el-linux" then "ld.so.1" else - if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else - if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else - abort "Don't know the name of the dynamic linker for this platform.") - else ""; + inherit dynamicLinker; crossAttrs = { shell = shell.crossDrv + shell.crossDrv.shellPath; -- cgit 1.4.1 From bb7067f882bf3c53ea68780a8ec0a7117f563253 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 19 Jun 2017 11:51:01 -0400 Subject: mingw-w64: Clean up, especially clarifying staging --- pkgs/os-specific/windows/mingw-w64/common.nix | 11 +++++++ pkgs/os-specific/windows/mingw-w64/default.nix | 38 +++---------------------- pkgs/os-specific/windows/mingw-w64/headers.nix | 13 +++++++++ pkgs/os-specific/windows/mingw-w64/pthreads.nix | 13 +++++++++ pkgs/top-level/all-packages.nix | 31 +++++++++----------- 5 files changed, 55 insertions(+), 51 deletions(-) create mode 100644 pkgs/os-specific/windows/mingw-w64/common.nix create mode 100644 pkgs/os-specific/windows/mingw-w64/headers.nix create mode 100644 pkgs/os-specific/windows/mingw-w64/pthreads.nix diff --git a/pkgs/os-specific/windows/mingw-w64/common.nix b/pkgs/os-specific/windows/mingw-w64/common.nix new file mode 100644 index 000000000000..ece2586dc806 --- /dev/null +++ b/pkgs/os-specific/windows/mingw-w64/common.nix @@ -0,0 +1,11 @@ +{ fetchurl }: + +rec { + version = "4.0.6"; + name = "mingw-w64-${version}"; + + src = fetchurl { + url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2"; + sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c"; + }; +} diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 49612b0b4618..697e03531822 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,36 +1,6 @@ -{ stdenv, fetchurl, binutils ? null, gccCross ? null -, onlyHeaders ? false -, onlyPthreads ? false -}: - -let - version = "4.0.6"; - name = "mingw-w64-${version}"; -in -stdenv.mkDerivation ({ - inherit name; - - src = fetchurl { - url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2"; - sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c"; - }; -} // -(if onlyHeaders then { - name = name + "-headers"; - preConfigure = '' - cd mingw-w64-headers - ''; - configureFlags = "--without-crt"; -} else if onlyPthreads then { - name = name + "-pthreads"; - preConfigure = '' - cd mingw-w64-libraries/winpthreads - ''; -} else { - buildInputs = [ gccCross binutils ]; - - crossConfig = gccCross.crossConfig; +{ stdenv, callPackage }: +stdenv.mkDerivation { + inherit (callPackage ./common.nix {}) name src; dontStrip = true; -}) -) +} diff --git a/pkgs/os-specific/windows/mingw-w64/headers.nix b/pkgs/os-specific/windows/mingw-w64/headers.nix new file mode 100644 index 000000000000..03dbf712e2e5 --- /dev/null +++ b/pkgs/os-specific/windows/mingw-w64/headers.nix @@ -0,0 +1,13 @@ +{ stdenvNoCC, callPackage }: + +let + inherit (callPackage ./common.nix {}) name src; + +in stdenvNoCC.mkDerivation { + name = name + "-headers"; + inherit src; + + preConfigure = '' + cd mingw-w64-headers + ''; +} diff --git a/pkgs/os-specific/windows/mingw-w64/pthreads.nix b/pkgs/os-specific/windows/mingw-w64/pthreads.nix new file mode 100644 index 000000000000..c585ab54ff89 --- /dev/null +++ b/pkgs/os-specific/windows/mingw-w64/pthreads.nix @@ -0,0 +1,13 @@ +{ stdenvNoCC, callPackage }: + +let + inherit (callPackage ./common.nix {}) name src; + +in stdenvNoCC.mkDerivation { + name = name + "-pthreads"; + inherit src; + + preConfigure = '' + cd mingw-w64-libraries/winpthreads + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c201715dfef3..882a308d2855 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5163,9 +5163,17 @@ with pkgs; gccApple = throw "gccApple is no longer supported"; + # Can't just overrideCC, because then the stdenv-cross mkDerivation will be + # thrown away. TODO: find a better solution for this. + crossLibcStdenv = buildPackages.makeStdenvCross { + inherit (buildPackages.buildPackages) stdenv; + inherit buildPlatform hostPlatform targetPlatform; + cc = buildPackages.gccCrossStageStatic; + }; + gccCrossStageStatic = assert targetPlatform != buildPlatform; let libcCross1 = - if targetPlatform.libc == "msvcrt" then windows.mingw_w64_headers + if targetPlatform.libc == "msvcrt" then __targetPackages.windows.mingw_w64_headers else if targetPlatform.libc == "libSystem" then darwin.xcode else null; in wrapCCCross { @@ -7800,13 +7808,7 @@ with pkgs; # Being redundant to avoid cycles on boot. TODO: find a better way glibcCross = callPackage ../development/libraries/glibc { installLocales = config.glibc.locales or false; - # Can't just overrideCC, because then the stdenv-cross mkDerivation will be - # thrown away. TODO: find a better solution for this. - stdenv = buildPackages.makeStdenvCross { - inherit (buildPackages.buildPackages) stdenv; - inherit buildPlatform hostPlatform targetPlatform; - cc = buildPackages.gccCrossStageStatic; - }; + stdenv = crossLibcStdenv; }; # We can choose: @@ -7815,7 +7817,7 @@ with pkgs; # hack fixes the hack, *sigh*. /**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross else if name == "uclibc" then uclibcCross - else if name == "msvcrt" then windows.mingw_w64 + else if name == "msvcrt" then __targetPackages.windows.mingw_w64 or windows.mingw_w64 else if name == "libSystem" then darwin.xcode else throw "Unknown libc"; @@ -12561,17 +12563,12 @@ with pkgs; }; mingw_w64 = callPackage ../os-specific/windows/mingw-w64 { - gccCross = gccCrossStageStatic; - binutils = binutils; + stdenv = crossLibcStdenv; }; - mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64 { - onlyHeaders = true; - }; + mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { }; - mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64 { - onlyPthreads = true; - }; + mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { }; pthreads = callPackage ../os-specific/windows/pthread-w32 { mingw_headers = mingw_headers3; -- cgit 1.4.1 From fc42ec0a5cf9962a6af9c2da39ff748b30299b67 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 19 Jun 2017 15:30:17 -0400 Subject: mingw-w64: Depend on own headers derivation Without this, a `#include ` resolves incorrectly. Either the headers weren't on the include path at all, or they only were for local, not system, imports. What's weird is this used to not be a problem. Not sure what other change in e.g. cc-wrapper would affect this. --- pkgs/os-specific/windows/mingw-w64/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 697e03531822..6e21826381b6 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,6 +1,7 @@ -{ stdenv, callPackage }: +{ stdenv, callPackage, windows }: stdenv.mkDerivation { inherit (callPackage ./common.nix {}) name src; + buildInputs = [ windows.mingw_w64_headers ]; dontStrip = true; } -- cgit 1.4.1 From f55ccbb60fb1022ce9d27595fc8200dd1d0da6db Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 24 Apr 2017 10:41:33 -0400 Subject: xbursttools: Fix eval at least so tests pass --- pkgs/tools/misc/xburst-tools/default.nix | 5 +++-- pkgs/top-level/all-packages.nix | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/misc/xburst-tools/default.nix b/pkgs/tools/misc/xburst-tools/default.nix index 408879a45345..c64ae609bcbb 100644 --- a/pkgs/tools/misc/xburst-tools/default.nix +++ b/pkgs/tools/misc/xburst-tools/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig -, gccCross ? null }: +, gccCross ? null, crossPrefix +}: let version = "2011-12-26"; @@ -18,7 +19,7 @@ stdenv.mkDerivation { ''; configureFlags = if gccCross != null then - "--enable-firmware CROSS_COMPILE=${gccCross.crossConfig}-" + "--enable-firmware CROSS_COMPILE=${crossPrefix}-" else ""; # Not to strip cross build binaries (this is for the gcc-cross-wrapper) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 882a308d2855..05fe28236b57 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4816,15 +4816,16 @@ with pkgs; x11_ssh_askpass = callPackage ../tools/networking/x11-ssh-askpass { }; - xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools { + xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools rec { # It needs a cross compiler for mipsel to build the firmware it will # load into the Ben Nanonote + crossPrefix = "mipsel-unknown-linux"; gccCross = let pkgsCross = nixpkgsFun { # Ben Nanonote system crossSystem = { - config = "mipsel-unknown-linux"; + config = crossPrefix; bigEndian = true; arch = "mips"; float = "soft"; @@ -4843,7 +4844,7 @@ with pkgs; }; }; in - pkgsCross.gccCrossStageStatic; + pkgsCross.buildPackages.gccCrossStageStatic; }; xclip = callPackage ../tools/misc/xclip { }; -- cgit 1.4.1 From 29c4d7f505c39930f0d457c9ba4570d6a768f67c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 30 May 2017 20:08:00 -0400 Subject: podofo: Simplify derivation Bunch of junk for linux and cross compilation that's no longer needed --- pkgs/development/libraries/podofo/default.nix | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pkgs/development/libraries/podofo/default.nix b/pkgs/development/libraries/podofo/default.nix index 1ba823540334..fde5c5e489c1 100644 --- a/pkgs/development/libraries/podofo/default.nix +++ b/pkgs/development/libraries/podofo/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig -, gcc5, openssl, libpng, lua5, pkgconfig, libidn, expat }: +, openssl, libpng, lua5, pkgconfig, libidn, expat +}: stdenv.mkDerivation rec { name = "podofo-0.9.5"; @@ -11,17 +12,9 @@ stdenv.mkDerivation rec { propagatedBuildInputs = [ zlib freetype libjpeg libtiff fontconfig openssl libpng libidn expat ]; - # Does Linux really need gcc5? Darwin doesn't seem to... - nativeBuildInputs = [ cmake pkgconfig ] ++ stdenv.lib.optional stdenv.isLinux gcc5; + nativeBuildInputs = [ cmake pkgconfig ]; - # Does Linux really need libc here? Darwin doesn't seem to... - buildInputs = [ lua5 ] ++ stdenv.lib.optional stdenv.isLinux stdenv.cc.libc; - - crossAttrs = { - propagatedBuildInputs = [ zlib.crossDrv freetype.crossDrv libjpeg.crossDrv - libtiff.crossDrv fontconfig.crossDrv openssl.crossDrv libpng.crossDrv - lua5.crossDrv stdenv.ccCross.libc ]; - }; + buildInputs = [ lua5 ]; cmakeFlags = "-DPODOFO_BUILD_SHARED=ON -DPODOFO_BUILD_STATIC=OFF"; -- cgit 1.4.1 From d016637629e16548a98c9c570136d8ba60e8c9cd Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Mon, 12 Jun 2017 00:29:51 +0000 Subject: podofo: unsimplify derivation a bit to avoid hash breakage --- pkgs/development/libraries/podofo/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/podofo/default.nix b/pkgs/development/libraries/podofo/default.nix index fde5c5e489c1..84709441b5e7 100644 --- a/pkgs/development/libraries/podofo/default.nix +++ b/pkgs/development/libraries/podofo/default.nix @@ -1,5 +1,6 @@ { stdenv, fetchurl, cmake, zlib, freetype, libjpeg, libtiff, fontconfig , openssl, libpng, lua5, pkgconfig, libidn, expat +, gcc5 # TODO(@Dridus) remove this at next hash break }: stdenv.mkDerivation rec { @@ -12,9 +13,11 @@ stdenv.mkDerivation rec { propagatedBuildInputs = [ zlib freetype libjpeg libtiff fontconfig openssl libpng libidn expat ]; - nativeBuildInputs = [ cmake pkgconfig ]; + # TODO(@Dridus) remove the ++ ghc5 at next hash break + nativeBuildInputs = [ cmake pkgconfig ] ++ stdenv.lib.optional stdenv.isLinux gcc5; - buildInputs = [ lua5 ]; + # TODO(@Dridus) remove the ++ libc at next hash break + buildInputs = [ lua5 ] ++ stdenv.lib.optional stdenv.isLinux stdenv.cc.libc; cmakeFlags = "-DPODOFO_BUILD_SHARED=ON -DPODOFO_BUILD_STATIC=OFF"; -- cgit 1.4.1 From 12795a706852539b8a29c796caced6295e7af459 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 30 May 2017 20:17:10 -0400 Subject: misc: Remove almost all uses of stdenv.{ccCross,binutils} --- pkgs/build-support/cc-wrapper/default.nix | 1 - pkgs/build-support/gcc-wrapper-old/default.nix | 1 - pkgs/development/compilers/gcc/4.5/default.nix | 2 +- pkgs/development/compilers/gcc/4.8/default.nix | 2 +- pkgs/development/compilers/gcc/4.9/default.nix | 2 +- pkgs/development/compilers/gcc/5/default.nix | 2 +- pkgs/development/compilers/gcc/6/default.nix | 2 +- pkgs/development/compilers/gcc/snapshot/default.nix | 2 +- pkgs/development/compilers/ghc/head.nix | 16 ++++++++-------- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 35a5e90583b8..0c624a1454a3 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -370,7 +370,6 @@ stdenv.mkDerivation { crossAttrs = { shell = shell.crossDrv + shell.crossDrv.shellPath; - libc = stdenv.ccCross.libc; }; meta = diff --git a/pkgs/build-support/gcc-wrapper-old/default.nix b/pkgs/build-support/gcc-wrapper-old/default.nix index a87c726e0a8b..f8a7c62edc73 100644 --- a/pkgs/build-support/gcc-wrapper-old/default.nix +++ b/pkgs/build-support/gcc-wrapper-old/default.nix @@ -61,7 +61,6 @@ stdenv.mkDerivation { crossAttrs = { shell = shell.crossDrv + shell.crossDrv.shellPath; - libc = stdenv.ccCross.libc; coreutils = coreutils.crossDrv; binutils = binutils.crossDrv; gcc = gcc.crossDrv; diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index 67981ad1056e..69197b923c38 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -283,7 +283,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index de9d3165b55e..38ff23f86a6d 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -401,7 +401,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index c5bebdf33003..04e67e44f773 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -407,7 +407,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index b4a74300d366..d4692c777514 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -422,7 +422,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 057acf9794e7..c439703fa8e4 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -404,7 +404,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index bb2c9d8a5c09..f3d8d27d90c6 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -405,7 +405,7 @@ stdenv.mkDerivation ({ NM_FOR_TARGET = "${targetPlatform.config}-nm"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + NIX_CC_CROSS = optionalString (targetPlatform == hostPlatform) builtins.toString stdenv.cc; dontStrip = true; configureFlags = '' ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 70200b2fa01b..f199048353c0 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -101,26 +101,26 @@ in stdenv.mkDerivation (rec { ''; configureFlags = [ - "CC=${stdenv.ccCross}/bin/${cross.config}-cc" - "LD=${stdenv.binutils}/bin/${cross.config}-ld" - "AR=${stdenv.binutils}/bin/${cross.config}-ar" - "NM=${stdenv.binutils}/bin/${cross.config}-nm" - "RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib" + "CC=${stdenv.cc}/bin/${cross.config}-cc" + "LD=${stdenv.cc}/bin/${cross.config}-ld" + "AR=${stdenv.cc}/bin/${cross.config}-ar" + "NM=${stdenv.cc}/bin/${cross.config}-nm" + "RANLIB=${stdenv.cc}/bin/${cross.config}-ranlib" "--target=${cross.config}" "--enable-bootstrap-with-devel-snapshot" ] ++ # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space"; - buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ]; + buildInputs = commonBuildInputs; configurePlatforms = []; passthru = { inherit bootPkgs cross; - cc = "${stdenv.ccCross}/bin/${cross.config}-cc"; + cc = "${stdenv.cc}/bin/${cross.config}-cc"; - ld = "${stdenv.binutils}/bin/${cross.config}-ld"; + ld = "${stdenv.cc}/bin/${cross.config}-ld"; }; }) -- cgit 1.4.1 From 38b2bd2f2853da7021e0efe001e7ec0a313afe44 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 30 May 2017 20:44:03 -0400 Subject: dropbear: Remove now-unneeded crossAttrs --- pkgs/tools/networking/dropbear/default.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkgs/tools/networking/dropbear/default.nix b/pkgs/tools/networking/dropbear/default.nix index aeace91df191..a918aa6375f3 100644 --- a/pkgs/tools/networking/dropbear/default.nix +++ b/pkgs/tools/networking/dropbear/default.nix @@ -22,13 +22,6 @@ stdenv.mkDerivation rec { makeFlags=VPATH=`cat $NIX_CC/nix-support/orig-libc`/lib ''; - crossAttrs = { - # This works for uclibc, at least. - preConfigure = '' - makeFlags=VPATH=`cat ${stdenv.ccCross}/nix-support/orig-libc`/lib - ''; - }; - patches = [ # Allow sessions to inherit the PATH from the parent dropbear. # Otherwise they only get the usual /bin:/usr/bin kind of PATH -- cgit 1.4.1 From f63f96ae355281bf89ea08f5c5af3b939878df5f Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Tue, 30 May 2017 22:20:15 -0400 Subject: zlib: don't really override CC at ay point but leave the preConfigure script as it was when not cross building in order to avoid hash breakage --- pkgs/development/libraries/zlib/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index dc6f0a455d86..e6468771cd40 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -1,4 +1,8 @@ -{ stdenv, fetchurl, static ? false }: +{ stdenv +, fetchurl +, buildPlatform, hostPlatform +, static ? false +}: let version = "1.2.11"; in @@ -24,7 +28,9 @@ stdenv.mkDerivation rec { setOutputFlags = false; outputDoc = "dev"; # single tiny man3 page - preConfigure = '' + # TODO(@Dridus) CC set by cc-wrapper setup-hook, so just empty out the preConfigure script when cross building, but leave the old incorrect script when not + # cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely. + preConfigure = stdenv.lib.optionalString (hostPlatform == buildPlatform) '' if test -n "$crossConfig"; then export CC=$crossConfig-gcc fi -- cgit 1.4.1 From 167b80ba76ae767b1d37458afb113683921d8c74 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 19 Jun 2017 22:18:22 -0400 Subject: coreutils: Modernize and fix for cross "--host=..." needs to be passed but crossAttrs overrides that. --- pkgs/tools/misc/coreutils/default.nix | 76 +++++++++++++++++------------------ 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index d87976cbc5e8..71fc791872f8 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -1,8 +1,9 @@ -{ lib, stdenv, buildPackages, fetchurl, perl, xz, gmp ? null +{ stdenv, lib, buildPackages +, autoconf, automake114x, texinfo, fetchurl, perl, xz, libiconv, gmp ? null +, hostPlatform, buildPlatform , aclSupport ? false, acl ? null , attrSupport ? false, attr ? null , selinuxSupport? false, libselinux ? null, libsepol ? null -, autoconf, automake114x, texinfo , withPrefix ? false , singleBinary ? "symlinks" # you can also pass "shebangs" or false }: @@ -23,10 +24,10 @@ stdenv.mkDerivation rec { # FIXME needs gcc 4.9 in bootstrap tools hardeningDisable = [ "stackprotector" ]; - patches = optional stdenv.isCygwin ./coreutils-8.23-4.cygwin.patch; + patches = optional hostPlatform.isCygwin ./coreutils-8.23-4.cygwin.patch; # The test tends to fail on btrfs and maybe other unusual filesystems. - postPatch = optionalString (!stdenv.isDarwin) '' + postPatch = optionalString (!hostPlatform.isDarwin) '' sed '2i echo Skipping dd sparse test && exit 0' -i ./tests/dd/sparse.sh sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh @@ -39,58 +40,54 @@ stdenv.mkDerivation rec { configureFlags = optional (singleBinary != false) ("--enable-single-binary" + optionalString (isString singleBinary) "=${singleBinary}") - ++ optional stdenv.isSunOS "ac_cv_func_inotify_init=no" - ++ optional withPrefix "--program-prefix=g"; + ++ optional hostPlatform.isSunOS "ac_cv_func_inotify_init=no" + ++ optional withPrefix "--program-prefix=g" + ++ optionals (hostPlatform != buildPlatform && hostPlatform.libc == "glibc") [ + # TODO(19b98110126fde7cbb1127af7e3fe1568eacad3d): Needed for fstatfs() I + # don't know why it is not properly detected cross building with glibc. + "fu_cv_sys_stat_statfs2_bsize=yes" + ]; + buildInputs = [ gmp ] ++ optional aclSupport acl ++ optional attrSupport attr - ++ optionals stdenv.isCygwin [ autoconf automake114x texinfo ] # due to patch - ++ optionals selinuxSupport [ libselinux libsepol ]; - - crossAttrs = { - buildInputs = [ gmp.crossDrv ] - ++ optional aclSupport acl.crossDrv - ++ optional attrSupport attr.crossDrv - ++ optionals selinuxSupport [ libselinux.crossDrv libsepol.crossDrv ] - ++ optional (stdenv ? ccCross.libc.libiconv) - stdenv.ccCross.libc.libiconv.crossDrv; - - # Prevents attempts of running 'help2man' on cross-built binaries. - PERL = "missing"; - - # Works around a bug with 8.26: - # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop. - preInstall = '' - sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|' - ''; - - postInstall = '' - rm $out/share/man/man1/* - cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1 - ''; - - # Needed for fstatfs() - # I don't know why it is not properly detected cross building with glibc. - configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ]; - doCheck = false; - }; + ++ optionals hostPlatform.isCygwin [ autoconf automake114x texinfo ] # due to patch + ++ optionals selinuxSupport [ libselinux libsepol ] + # TODO(@Ericson2314): Investigate whether Darwin could benefit too + ++ optional (hostPlatform != buildPlatform && hostPlatform.libc != "glibc") libiconv; # The tests are known broken on Cygwin # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025), # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351), # and {Open,Free}BSD. # With non-standard storeDir: https://github.com/NixOS/nix/issues/512 - doCheck = stdenv ? glibc && builtins.storeDir == "/nix/store"; + doCheck = hostPlatform == buildPlatform + && hostPlatform.libc == "glibc" + && builtins.storeDir == "/nix/store"; + + # Prevents attempts of running 'help2man' on cross-built binaries. + ${if hostPlatform == buildPlatform then null else "PERL"} = "missing"; # Saw random failures like ‘help2man: can't get '--help' info from # man/sha512sum.td/sha512sum’. enableParallelBuilding = false; NIX_LDFLAGS = optionalString selinuxSupport "-lsepol"; - FORCE_UNSAFE_CONFIGURE = optionalString stdenv.isSunOS "1"; + FORCE_UNSAFE_CONFIGURE = optionalString hostPlatform.isSunOS "1"; + + makeFlags = optionalString hostPlatform.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0"; + + # Works around a bug with 8.26: + # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop. + ${if hostPlatform == buildPlatform then null else "preInstall"} = '' + sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|' + ''; - makeFlags = optionalString stdenv.isDarwin "CFLAGS=-D_FORTIFY_SOURCE=0"; + ${if hostPlatform == buildPlatform then null else "postInstall"} = '' + rm $out/share/man/man1/* + cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1 + ''; meta = { homepage = http://www.gnu.org/software/coreutils/; @@ -109,4 +106,5 @@ stdenv.mkDerivation rec { maintainers = [ maintainers.eelco ]; }; + } -- cgit 1.4.1 From 8b22e497f2bbffca98dc73502b1873595fb36ea9 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 31 May 2017 00:53:47 -0400 Subject: vim: Modernize derivation, hopefully fixing cross --- pkgs/applications/editors/vim/default.nix | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix index 98e9a47a7604..b8fee7bd1e24 100644 --- a/pkgs/applications/editors/vim/default.nix +++ b/pkgs/applications/editors/vim/default.nix @@ -6,7 +6,9 @@ sha256 = "18ifhv5q9prd175q3vxbqf6qyvkk6bc7d2lhqdk0q78i68kv9y0c"; } # apple frameworks -, Carbon, Cocoa }: +, Carbon, Cocoa +, buildPlatform, hostPlatform +}: let common = callPackage ./common.nix {}; @@ -17,12 +19,26 @@ stdenv.mkDerivation rec { inherit (common) version src postPatch hardeningDisable enableParallelBuilding meta; buildInputs = [ ncurses pkgconfig ] - ++ stdenv.lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; + ++ stdenv.lib.optionals hostPlatform.isDarwin [ Carbon Cocoa ]; nativeBuildInputs = [ gettext ]; configureFlags = [ "--enable-multibyte" "--enable-nls" + ] ++ stdenv.lib.optionals (hostPlatform != buildPlatform) [ + "vim_cv_toupper_broken=no" + "--with-tlib=ncurses" + "vim_cv_terminfo=yes" + "vim_cv_tty_group=tty" + "vim_cv_tty_mode=0660" + "vim_cv_getcwd_broken=no" + "vim_cv_stat_ignores_slash=yes" + "ac_cv_sizeof_int=4" + "vim_cv_memmove_handles_overlap=yes" + "vim_cv_memmove_handles_overlap=yes" + + # TODO(@Ericson2314): wont' be needed soon. + "STRIP=${hostPlatform.config}-strip" ]; postInstall = '' @@ -31,22 +47,6 @@ stdenv.mkDerivation rec { cp "${vimrc}" $out/share/vim/vimrc ''; - crossAttrs = { - configureFlags = [ - "vim_cv_toupper_broken=no" - "--with-tlib=ncurses" - "vim_cv_terminfo=yes" - "vim_cv_tty_group=tty" - "vim_cv_tty_mode=0660" - "vim_cv_getcwd_broken=no" - "vim_cv_stat_ignores_slash=yes" - "ac_cv_sizeof_int=4" - "vim_cv_memmove_handles_overlap=yes" - "vim_cv_memmove_handles_overlap=yes" - "STRIP=${stdenv.cross.config}-strip" - ]; - }; - __impureHostDeps = [ "/dev/ptmx" ]; # To fix the trouble in vim73, that it cannot cross-build with this patch -- cgit 1.4.1 From 05b3c87d9d9df6a8eac118f6d243f5a94649d66a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 2 Jun 2017 17:35:13 -0400 Subject: busybox: Modernize and fix cross --- pkgs/os-specific/linux/busybox/default.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix index 4956f13950dd..e1ea8fa8fdd2 100644 --- a/pkgs/os-specific/linux/busybox/default.nix +++ b/pkgs/os-specific/linux/busybox/default.nix @@ -1,8 +1,9 @@ -{ stdenv, lib, fetchurl, glibc, musl +{ stdenv, lib, buildPackages, fetchurl , enableStatic ? false , enableMinimal ? false -, useMusl ? false +, useMusl ? false, musl , extraConfig ? "" +, buildPlatform, hostPlatform }: let @@ -71,20 +72,16 @@ stdenv.mkDerivation rec { ''; postConfigure = lib.optionalString useMusl '' - makeFlagsArray+=("CC=gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib") + makeFlagsArray+=("CC=${stdenv.cc.prefix}gcc -isystem ${musl}/include -B${musl}/lib -L${musl}/lib") ''; - buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ]; + nativeBuildInputs = lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc; - crossAttrs = { - extraCrossConfig = '' - CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cross.config}-" - ''; + buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ]; - postConfigure = stdenv.lib.optionalString useMusl '' - makeFlagsArray+=("CC=$crossConfig-gcc -isystem ${musl.crossDrv}/include -B${musl.crossDrv}/lib -L${musl.crossDrv}/lib") - ''; - }; + extraCrossConfig = if hostPlatform == buildPlatform then null else '' + CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}" + ''; enableParallelBuilding = true; -- cgit 1.4.1 From 7bdacad8b39568611e84da5aa3b37e4e70641012 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 11:21:03 -0400 Subject: ed: Modernize and fix for cross --- pkgs/applications/editors/ed/default.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix index ec56667a4ba6..053e1d22af31 100644 --- a/pkgs/applications/editors/ed/default.nix +++ b/pkgs/applications/editors/ed/default.nix @@ -1,4 +1,6 @@ -{ fetchurl, stdenv }: +{ stdenv, fetchurl +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "ed-${version}"; @@ -28,11 +30,12 @@ stdenv.mkDerivation rec { make: *** [check] Error 127 */ - doCheck = !stdenv.isDarwin; + doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform); - crossAttrs = { - compileFlags = [ "CC=${stdenv.cross.config}-gcc" ]; - }; + configureFlags = if hostPlatform == buildPlatform then null else [ + "--exec-prefix=${stdenv.cc.prefix}" + "CC=${stdenv.cc.prefix}cc" + ]; meta = { description = "An implementation of the standard Unix editor"; -- cgit 1.4.1 From ef0b07e94a2fa745d731b0308dbc175be58d0184 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 11:27:33 -0400 Subject: gnu patch: Fix for cross --- pkgs/tools/text/gnupatch/default.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix index adbd69154ecc..57543eb303b0 100644 --- a/pkgs/tools/text/gnupatch/default.nix +++ b/pkgs/tools/text/gnupatch/default.nix @@ -1,4 +1,7 @@ -{ stdenv, fetchurl, ed }: +{ stdenv, fetchurl +, ed +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "patch-2.7.5"; @@ -10,11 +13,11 @@ stdenv.mkDerivation rec { buildInputs = stdenv.lib.optional doCheck ed; - crossAttrs = { - configureFlags = [ "ac_cv_func_strnlen_working=yes" ]; - }; + configureFlags = if hostPlatform == buildPlatform then null else [ + "ac_cv_func_strnlen_working=yes" + ]; - doCheck = true; + doCheck = hostPlatform == buildPlatform; meta = { description = "GNU Patch, a program to apply differences to files"; -- cgit 1.4.1 From f75ad79375d3596d6402af881454ba8c5260b866 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 1 Jun 2017 12:24:16 -0400 Subject: bash: Modernize derivation, hopefully fixing cross compilation --- pkgs/shells/bash/4.4.nix | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/pkgs/shells/bash/4.4.nix b/pkgs/shells/bash/4.4.nix index 061f183e96e3..e2defc2bf373 100644 --- a/pkgs/shells/bash/4.4.nix +++ b/pkgs/shells/bash/4.4.nix @@ -1,15 +1,16 @@ -{ stdenv, fetchurl, readline70 ? null, interactive ? false, texinfo ? null -, binutils ? null, bison +{ stdenv, buildPackages +, fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison +, buildPlatform, hostPlatform +, interactive ? false }: assert interactive -> readline70 != null; -assert stdenv.isDarwin -> binutils != null; +assert hostPlatform.isDarwin -> binutils != null; let version = "4.4"; realName = "bash-${version}"; shortName = "bash44"; - baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline"; sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"; upstreamPatches = @@ -22,7 +23,7 @@ let in import ./bash-4.4-patches.nix patch; - inherit (stdenv.lib) optional optionalString; + inherit (stdenv.lib) optional optionals; in stdenv.mkDerivation rec { @@ -52,26 +53,25 @@ stdenv.mkDerivation rec { patchFlags = "-p0"; patches = upstreamPatches - ++ optional stdenv.isCygwin ./cygwin-bash-4.3.33-1.src.patch; - - crossAttrs = { - configureFlags = baseConfigureFlags + - " bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" + - optionalString stdenv.isCygwin '' - --without-libintl-prefix --without-libiconv-prefix - --with-installed-readline - bash_cv_dev_stdin=present - bash_cv_dev_fd=standard - bash_cv_termcap_lib=libncurses - ''; - }; - - configureFlags = baseConfigureFlags; + ++ optional hostPlatform.isCygwin ./cygwin-bash-4.3.33-1.src.patch; + + configureFlags = [ + (if interactive then "--with-installed-readline" else "--disable-readline") + ] ++ optionals (hostPlatform != buildPlatform) [ + "bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" + ] ++ optionals hostPlatform.isCygwin [ + "--without-libintl-prefix --without-libiconv-prefix" + "--with-installed-readline" + "bash_cv_dev_stdin=present" + "bash_cv_dev_fd=standard" + "bash_cv_termcap_lib=libncurses" + ]; # Note: Bison is needed because the patches above modify parse.y. nativeBuildInputs = [bison] ++ optional (texinfo != null) texinfo - ++ optional stdenv.isDarwin binutils; + ++ optional hostPlatform.isDarwin binutils + ++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc; buildInputs = optional interactive readline70; -- cgit 1.4.1 From c54c3cb5cef4ff05ea7af017afbf8c2e294c1f2d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 16:57:52 -0400 Subject: mpfs: Fix for cross by disabling check check phase is now only disabled by *default* for cross, but mpfr was forcing it always. --- pkgs/development/libraries/mpfr/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix index 8dbe150e2cb3..4f9a9fb9bd0e 100644 --- a/pkgs/development/libraries/mpfr/default.nix +++ b/pkgs/development/libraries/mpfr/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchurl, gmp }: +{ stdenv, fetchurl, gmp +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "mpfr-3.1.3"; @@ -19,10 +21,10 @@ stdenv.mkDerivation rec { hardeningDisable = [ "stackprotector" ]; configureFlags = - stdenv.lib.optional stdenv.isSunOS "--disable-thread-safe" ++ - stdenv.lib.optional stdenv.is64bit "--with-pic"; + stdenv.lib.optional hostPlatform.isSunOS "--disable-thread-safe" ++ + stdenv.lib.optional hostPlatform.is64bit "--with-pic"; - doCheck = true; + doCheck = hostPlatform == buildPlatform; enableParallelBuilding = true; -- cgit 1.4.1 From 2e337fe969a55f66dcd41715b73f9c68acc38867 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 19:36:59 -0400 Subject: libelf: Modernize and fix for cross --- pkgs/development/libraries/libelf/cross-ar.patch | 11 +++++++++++ pkgs/development/libraries/libelf/default.nix | 17 ++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 pkgs/development/libraries/libelf/cross-ar.patch diff --git a/pkgs/development/libraries/libelf/cross-ar.patch b/pkgs/development/libraries/libelf/cross-ar.patch new file mode 100644 index 000000000000..e282d9005dbb --- /dev/null +++ b/pkgs/development/libraries/libelf/cross-ar.patch @@ -0,0 +1,11 @@ +--- a/lib/Makefile.in ++++ b/lib/Makefile.in +@@ -27,7 +27,7 @@ installdirs = $(libdir) $(includedir) $(includedir)/libelf + + CC = @CC@ + LD = @LD@ +-AR = ar ++AR ?= ar + MV = mv -f + RM = rm -f + LN_S = @LN_S@ diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix index 5027afa397ac..dcd5d1d7a93e 100644 --- a/pkgs/development/libraries/libelf/default.nix +++ b/pkgs/development/libraries/libelf/default.nix @@ -1,4 +1,7 @@ -{ fetchurl, stdenv, gettext, glibc }: +{ stdenv, fetchurl +, gettext, glibc +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "libelf-0.8.13"; @@ -8,20 +11,20 @@ stdenv.mkDerivation rec { sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"; }; + # TODO(@Ericson2314) Make unconditional next hash break + patches = if hostPlatform == buildPlatform then null else [ + ./cross-ar.patch + ]; + doCheck = true; # FIXME needs gcc 4.9 in bootstrap tools hardeningDisable = [ "stackprotector" ]; - # For cross-compiling, native glibc is needed for the "gencat" program. - crossAttrs = { - nativeBuildInputs = [ gettext glibc ]; - }; - # Libelf's custom NLS macros fail to determine the catalog file extension on # Darwin, so disable NLS for now. # FIXME: Eventually make Gettext a build input on all platforms. - configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-nls"; + configureFlags = stdenv.lib.optional hostPlatform.isDarwin "--disable-nls"; nativeBuildInputs = [ gettext ]; -- cgit 1.4.1 From af8d1a4acebdb723f75c20512f4458d2bc82e8ae Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 20:28:29 -0400 Subject: binutils: Fix build != host == target --- pkgs/development/tools/misc/binutils/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 23ea7aed2511..82eb7f77bb4c 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -50,7 +50,8 @@ stdenv.mkDerivation rec { ++ [ "info" ] ++ optional (targetPlatform == hostPlatform) "dev"; - nativeBuildInputs = [ bison ]; + nativeBuildInputs = [ bison ] + ++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc; buildInputs = [ zlib ]; inherit noSysDirs; -- cgit 1.4.1 From b93e6034d5c37ce2f6faa632a08a619b5c01b52f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 20:35:03 -0400 Subject: libsigsegv: Fix for cross by disabling check Check phase is now only disabled *by default* for cross, but this package was forcing it unconditionally. --- pkgs/development/libraries/libsigsegv/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/libsigsegv/default.nix b/pkgs/development/libraries/libsigsegv/default.nix index 0e644686af02..961b3b2d883b 100644 --- a/pkgs/development/libraries/libsigsegv/default.nix +++ b/pkgs/development/libraries/libsigsegv/default.nix @@ -1,4 +1,6 @@ -{ fetchurl, stdenv }: +{ stdenv, fetchurl +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "libsigsegv-2.11"; @@ -8,7 +10,7 @@ stdenv.mkDerivation rec { sha256 = "063swdvq7mbmc1clv0rnh20grwln1zfc2qnm0sa1hivcxyr2wz6x"; }; - doCheck = true; + doCheck = hostPlatform == buildPlatform; meta = { homepage = http://www.gnu.org/software/libsigsegv/; -- cgit 1.4.1 From ff6ab1b3c4f13bb2972b06ab9b881b49ef7b521b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 3 Jun 2017 21:11:40 -0400 Subject: pcre: Modernize and fix cross --- pkgs/development/libraries/pcre/default.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index 21de038f7d63..93e32529592e 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -1,5 +1,7 @@ { stdenv, fetchurl -, windows ? null, variant ? null, pcre +, pcre, windows ? null +, buildPlatform, hostPlatform +, variant ? null }: with stdenv.lib; @@ -31,7 +33,9 @@ in stdenv.mkDerivation rec { patches = [ ./CVE-2017-7186.patch ]; - doCheck = with stdenv; !(isCygwin || isFreeBSD); + buildInputs = optional (hostPlatform.libc == "msvcrt") windows.mingw_w64_pthreads; + + doCheck = !(with hostPlatform; isCygwin || isFreeBSD) && hostPlatform == buildPlatform; # XXX: test failure on Cygwin # we are running out of stack on both freeBSDs on Hydra @@ -42,10 +46,6 @@ in stdenv.mkDerivation rec { ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib} ''; - crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") { - buildInputs = [ windows.mingw_w64_pthreads.crossDrv ]; - }; - meta = { homepage = "http://www.pcre.org/"; description = "A library for Perl Compatible Regular Expressions"; -- cgit 1.4.1 From 54089620f5ef77f7c1ed3b5db497986423f0d0f4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 4 Jun 2017 13:29:02 -0400 Subject: libpmc: Fix for cross by disabling check Check phase is now only disabled *by default* for cross, but this package was forcing it unconditionally. --- pkgs/development/libraries/libmpc/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/libmpc/default.nix b/pkgs/development/libraries/libmpc/default.nix index 0d3c9c0997c1..1bad236e0447 100644 --- a/pkgs/development/libraries/libmpc/default.nix +++ b/pkgs/development/libraries/libmpc/default.nix @@ -1,4 +1,8 @@ -{ fetchurl, stdenv, gmp, mpfr }: +{ stdenv, fetchurl +, gmp, mpfr +, buildPlatform, hostPlatform +}: + let version = "1.0.3"; in @@ -14,7 +18,7 @@ stdenv.mkDerivation rec { CFLAGS = "-I${gmp.dev}/include"; - doCheck = true; + doCheck = hostPlatform == buildPlatform; # FIXME needs gcc 4.9 in bootstrap tools hardeningDisable = [ "stackprotector" ]; -- cgit 1.4.1 From d710c2d9430f0ebc3f743c4ca5c6e3e5718c149e Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Sun, 4 Jun 2017 17:32:55 +0000 Subject: findutils: modernize and fix cross --- pkgs/tools/misc/findutils/default.nix | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/misc/findutils/default.nix b/pkgs/tools/misc/findutils/default.nix index 53d75485d5ca..06a140fed502 100644 --- a/pkgs/tools/misc/findutils/default.nix +++ b/pkgs/tools/misc/findutils/default.nix @@ -1,4 +1,9 @@ -{ stdenv, fetchurl, coreutils }: +{ stdenv, fetchurl +, coreutils +, buildPlatform, hostPlatform +}: + +let inherit (stdenv.lib) optionals; in stdenv.mkDerivation rec { name = "findutils-4.6.0"; @@ -10,20 +15,18 @@ stdenv.mkDerivation rec { patches = [ ./memory-leak.patch ./no-install-statedir.patch ]; - buildInputs = [ coreutils ]; # bin/updatedb script needs to call sort + buildInputs = optionals (hostPlatform == buildPlatform) [ coreutils ]; # bin/updatedb script needs to call sort # Since glibc-2.25 the i686 tests hang reliably right after test-sleep. - doCheck = !stdenv.isDarwin && (stdenv.system != "i686-linux"); + doCheck + = !hostPlatform.isDarwin + && !(hostPlatform.libc == "glibc" && hostPlatform.isi686) + && hostPlatform == buildPlatform; outputs = [ "out" "info" ]; configureFlags = [ "--localstatedir=/var/cache" ]; - crossAttrs = { - # Fix the 'buildInputs = [ coreutils ]' above - that adds the cross coreutils to PATH :( - propagatedBuildInputs = [ ]; - }; - enableParallelBuilding = true; meta = { -- cgit 1.4.1 From bef622a4e836999da0d398f78f3968f6b7c629b3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 4 Jun 2017 17:50:36 -0400 Subject: unzip: Fix for cross --- pkgs/tools/archivers/unzip/cross-cc.patch | 12 ++++++++++++ pkgs/tools/archivers/unzip/default.nix | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 pkgs/tools/archivers/unzip/cross-cc.patch diff --git a/pkgs/tools/archivers/unzip/cross-cc.patch b/pkgs/tools/archivers/unzip/cross-cc.patch new file mode 100644 index 000000000000..3d38ffdef6e3 --- /dev/null +++ b/pkgs/tools/archivers/unzip/cross-cc.patch @@ -0,0 +1,12 @@ +--- a/unix/Makefile ++++ b/unix/Makefile +@@ -42,9 +42,7 @@ + # such as -DDOSWILD). + + # UnZip flags +-CC = cc# try using "gcc" target rather than changing this (CC and LD + LD = $(CC)# must match, else "unresolved symbol: ___main" is possible) +-AS = as + LOC = $(D_USE_BZ2) $(LOCAL_UNZIP) + AF = $(LOC) + CFLAGS = -O diff --git a/pkgs/tools/archivers/unzip/default.nix b/pkgs/tools/archivers/unzip/default.nix index b9fa760c019b..ad484b3d4d97 100644 --- a/pkgs/tools/archivers/unzip/default.nix +++ b/pkgs/tools/archivers/unzip/default.nix @@ -1,5 +1,8 @@ -{ stdenv, fetchurl, bzip2 -, enableNLS ? false, libnatspec }: +{ stdenv, fetchurl +, bzip2 +, enableNLS ? false, libnatspec +, buildPlatform, hostPlatform +}: stdenv.mkDerivation { name = "unzip-6.0"; @@ -25,14 +28,15 @@ stdenv.mkDerivation { url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; name = "unzip-6.0-natspec.patch"; sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; - }); + }) + ++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch; nativeBuildInputs = [ bzip2 ]; buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; makefile = "unix/Makefile"; - NIX_LDFLAGS = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec"; + ${"NIX_${stdenv.cc.infixSalt_}LDFLAGS"} = [ "-lbz2" ] ++ stdenv.lib.optional enableNLS "-lnatspec"; buildFlags = "generic D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2"; -- cgit 1.4.1 From be3f18d79e2d232c2cbd2a394c34476af8413f0a Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Sun, 4 Jun 2017 21:50:58 +0000 Subject: ddrescue: modernize and fix cross (hopefully) Carefully do not add attributes for cross unless in cross, to avoid hash breakage --- pkgs/tools/system/ddrescue/default.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/system/ddrescue/default.nix b/pkgs/tools/system/ddrescue/default.nix index 3dcbf59d4d7d..0b94f328b84a 100644 --- a/pkgs/tools/system/ddrescue/default.nix +++ b/pkgs/tools/system/ddrescue/default.nix @@ -1,4 +1,9 @@ -{ stdenv, fetchurl, lzip }: +{ stdenv +, fetchurl, lzip +, hostPlatform, buildPlatform +}: + +let inherit (stdenv.lib) optionals; in stdenv.mkDerivation rec { name = "ddrescue-1.22"; @@ -10,7 +15,12 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ lzip ]; - doCheck = true; + doCheck = hostPlatform == buildPlatform; + + ${if hostPlatform != buildPlatform then "crossPlatforms" else null} = [ ]; + ${if hostPlatform != buildPlatform then "configureFlags" else null} = [ + "CXX=${stdenv.cc.prefix}c++" + ]; meta = with stdenv.lib; { description = "GNU ddrescue, a data recovery tool"; -- cgit 1.4.1 From 502902f1c6d16faec2ecca669e4cc77987fb676f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 4 Jun 2017 19:15:31 -0400 Subject: lynx: Fix for cross Needed C toolchain targeting build platform --- pkgs/applications/networking/browsers/lynx/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/browsers/lynx/default.nix b/pkgs/applications/networking/browsers/lynx/default.nix index 42f454191989..bbf034a13424 100644 --- a/pkgs/applications/networking/browsers/lynx/default.nix +++ b/pkgs/applications/networking/browsers/lynx/default.nix @@ -1,5 +1,7 @@ -{ stdenv, fetchurl, ncurses, gzip, pkgconfig +{ stdenv, buildPackages +, fetchurl, pkgconfig, ncurses, gzip , sslSupport ? true, openssl ? null +, buildPlatform, hostPlatform }: assert sslSupport -> openssl != null; @@ -15,7 +17,9 @@ stdenv.mkDerivation rec { configureFlags = [ "--enable-widec" ] ++ stdenv.lib.optional sslSupport "--with-ssl"; - nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig; + nativeBuildInputs = stdenv.lib.optional sslSupport pkgconfig + ++ stdenv.lib.optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc; + buildInputs = [ ncurses gzip ] ++ stdenv.lib.optional sslSupport openssl.dev; meta = with stdenv.lib; { -- cgit 1.4.1 From 7c754b1e3bb769da01c49342bc23816605928bf8 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 4 Jun 2017 19:24:50 -0400 Subject: mpg123: Modernize and fix for cross Do not even think about configureFlags unless in cross, to avoid hash breaking when not in cross. --- pkgs/applications/audio/mpg123/default.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/audio/mpg123/default.nix b/pkgs/applications/audio/mpg123/default.nix index 9004a46115ee..2909dd70ce9a 100644 --- a/pkgs/applications/audio/mpg123/default.nix +++ b/pkgs/applications/audio/mpg123/default.nix @@ -1,4 +1,7 @@ -{stdenv, fetchurl, alsaLib }: +{ stdenv +, fetchurl, alsaLib +, buildPlatform, hostPlatform +}: stdenv.mkDerivation rec { name = "mpg123-1.23.8"; @@ -10,10 +13,8 @@ stdenv.mkDerivation rec { buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib; - crossAttrs = { - configureFlags = if stdenv.cross ? mpg123 then - "--with-cpu=${stdenv.cross.mpg123.cpu}" else ""; - }; + ${if buildPlatform != hostPlatform then "configureFlags" else null} = + stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}"; meta = { description = "Fast console MPEG Audio Player and decoder library"; -- cgit 1.4.1 From 198dceccbe5414a5fd72ca83624c0cc715db1aad Mon Sep 17 00:00:00 2001 From: Ross MacLeod Date: Mon, 5 Jun 2017 04:37:47 +0000 Subject: gcc5: set --build and --host in the case where those differ and make sure to have a build cc-wrapper around as well --- pkgs/development/compilers/gcc/5/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index d4692c777514..e95ef92c3f65 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -35,6 +35,7 @@ , cloog # unused; just for compat with gcc4, as we override the parameter on some places , darwin ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -312,6 +313,7 @@ stdenv.mkDerivation ({ ++ (optionals langJava [ boehmgc zip unzip ]) ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) ++ (optionals (targetPlatform != hostPlatform) [binutils]) + ++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc]) ++ (optionals langAda [gnatboot]) ++ (optionals langVhdl [gnat]) @@ -449,6 +451,8 @@ stdenv.mkDerivation ({ ) } ${if langAda then " --enable-libada" else ""} + --build=${buildPlatform.config} + --host=${hostPlatform.config} --target=${targetPlatform.config} ${xwithArch} ${xwithCpu} -- cgit 1.4.1 From f43ae985a68e515197c57de5ab8413d63ae6ef1a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 24 Apr 2017 16:00:11 -0400 Subject: ios-cross: Just properly use the cc-wrapper No other downstream derivations are needed anymore. --- pkgs/os-specific/darwin/ios-cross/default.nix | 37 ++++++--------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/pkgs/os-specific/darwin/ios-cross/default.nix b/pkgs/os-specific/darwin/ios-cross/default.nix index e5375ef60915..e0981d48c8c9 100644 --- a/pkgs/os-specific/darwin/ios-cross/default.nix +++ b/pkgs/os-specific/darwin/ios-cross/default.nix @@ -6,7 +6,7 @@ , stdenv , coreutils , gnugrep -, targetPlatform +, hostPlatform, targetPlatform }: /* As of this writing, known-good prefix/arch/simulator triples: @@ -28,14 +28,14 @@ let sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}${sdkVer}.sdk"; - /* TODO: Properly integrate with gcc-cross-wrapper */ - wrapper = import ../../../build-support/cc-wrapper { - inherit stdenv coreutils gnugrep; +in (import ../../../build-support/cc-wrapper { + inherit stdenv coreutils gnugrep runCommand; nativeTools = false; nativeLibc = false; inherit binutils; libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}"; - cc = clang; + inherit (clang) cc; + inherit hostPlatform targetPlatform; extraBuildCommands = '' if ! [ -d ${sdk} ]; then echo "You must have ${sdkVer} of the iPhone${sdkType} sdk installed at ${sdk}" >&2 @@ -49,27 +49,6 @@ let # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before ''; - }; -in { - cc = runCommand "${prefix}-cc" { passthru = { inherit sdkType sdkVer sdk; }; } '' - mkdir -p $out/bin - ln -sv ${wrapper}/bin/clang $out/bin/${prefix}-cc - mkdir -p $out/nix-support - echo ${llvm} > $out/nix-support/propagated-native-build-inputs - cat > $out/nix-support/setup-hook <