From d72647bc055842e8bf65443b331f8a88808e5e15 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 22 Sep 2017 19:44:06 -0400 Subject: [PATCH 1/9] ghc-6.10.2-binary: Remove dead Darwin code This looks like a WIP attempt from 2008 --- .../compilers/ghc/6.10.2-binary.nix | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix index 60749a29b58b..1b9d81d2f121 100644 --- a/pkgs/development/compilers/ghc/6.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix @@ -58,29 +58,7 @@ stdenv.mkDerivation rec { # calls install-strip ... dontBuild = true; - # The binaries for Darwin use frameworks, so fake those frameworks, - # and create some wrapper scripts that set DYLD_FRAMEWORK_PATH so - # that the executables work with no special setup. postInstall = - (if stdenv.isDarwin then - '' - mkdir -p $out/frameworks/GMP.framework/Versions/A - ln -s ${gmp.out}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP - ln -s ${gmp.out}/lib/libgmp.dylib $out/frameworks/GMP.framework/Versions/A/GMP - # !!! fix this - mkdir -p $out/frameworks/GNUeditline.framework/Versions/A - ln -s ${libedit}/lib/libeditline.dylib $out/frameworks/GNUeditline.framework/GNUeditline - ln -s ${libedit}/lib/libeditline.dylib $out/frameworks/GNUeditline.framework/Versions/A/GNUeditline - - mv $out/bin $out/bin-orig - mkdir $out/bin - for i in $(cd $out/bin-orig && ls); do - echo \"#! $SHELL -e\" >> $out/bin/$i - echo \"DYLD_FRAMEWORK_PATH=$out/frameworks exec $out/bin-orig/$i -framework-path $out/frameworks \\\"\\$@\\\"\" >> $out/bin/$i - chmod +x $out/bin/$i - done - '' else "") - + '' # bah, the passing gmp doesn't work, so let's add it to the final package.conf in a quick but dirty way sed -i "s@^\(.*pkgName = PackageName \"rts\".*\libraryDirs = \\[\)\(.*\)@\\1\"${gmp.out}/lib\",\2@" $out/lib/ghc-${version}/package.conf From 17de4355334f450194b0022b9a09f9b13cdeba20 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 22 Sep 2017 13:59:43 -0400 Subject: [PATCH 2/9] ghc prebuilt: Don't hardcode the version in a few more places This removes noise in the diff, making creating new versions easier. No hashes should be changed. --- pkgs/development/compilers/ghc/7.0.4-binary.nix | 6 +++--- pkgs/development/compilers/ghc/7.4.2-binary.nix | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix index 6140cde4a9ef..a53098937ce8 100644 --- a/pkgs/development/compilers/ghc/7.0.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix @@ -74,9 +74,9 @@ stdenv.mkDerivation rec { install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 } - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.0.4/utils/ghc-pwd/dist/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.0.4/utils/hpc/dist/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.0.4/ghc/stage2/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do fix $(find . -type f -name $file) diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index 100bb87768b5..cfbc1e8dd170 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -79,9 +79,9 @@ stdenv.mkDerivation rec { install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 } - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.4.2/utils/ghc-pwd/dist-install/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.4.2/utils/hpc/dist-install/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-7.4.2/ghc/stage2/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist-install/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist-install/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do fix $(find . -type f -name $file) @@ -107,10 +107,10 @@ stdenv.mkDerivation rec { dontBuild = true; preInstall = stdenv.lib.optionalString stdenv.isDarwin '' - mkdir -p $out/lib/ghc-7.4.2 + mkdir -p $out/lib/ghc-${version} mkdir -p $out/bin ln -s ${libiconv}/lib/libiconv.dylib $out/bin - ln -s ${libiconv}/lib/libiconv.dylib $out/lib/ghc-7.4.2/libiconv.dylib + ln -s ${libiconv}/lib/libiconv.dylib $out/lib/ghc-${version}/libiconv.dylib ln -s ${libiconv}/lib/libiconv.dylib utils/ghc-cabal/dist-install/build/tmp ''; From a8ef3f67420fb9b87c5b238c8fc93d4cda446a34 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 10 Sep 2017 15:36:48 -0400 Subject: [PATCH 3/9] ghc prebuilt: Clean up syntax, without changes hashes If I'm going to make a bunch more of these, I think it's a good idea to make them more uniform first. --- .../compilers/ghc/6.10.2-binary.nix | 28 +++++++++-------- .../compilers/ghc/7.0.4-binary.nix | 30 +++++++++---------- .../compilers/ghc/7.4.2-binary.nix | 30 +++++++++---------- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix index 1b9d81d2f121..99e54ff5f673 100644 --- a/pkgs/development/compilers/ghc/6.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix @@ -1,24 +1,26 @@ -{stdenv, lib, fetchurl, perl, libedit, ncurses5, gmp}: +{ stdenv +, fetchurl, perl +, libedit, ncurses5, gmp +}: stdenv.mkDerivation rec { version = "6.10.2"; name = "ghc-${version}-binary"; - src = - if stdenv.system == "i686-linux" then - fetchurl { + src = fetchurl ({ + "i686-linux" = { # This binary requires libedit.so.0 (rather than libedit.so.2). url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; sha256 = "1fw0zr2qshlpk8s0d16k27zcv5263nqdg2xds5ymw8ff6qz9rz9b"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { + }; + "x86_64-linux" = { # Idem. url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; sha256 = "1rd2j7lmcfsm2rdfb5g6q0l8dz3sxadk5m3d2f69d4a6g4p4h7jj"; - } - else throw "cannot bootstrap GHC on this platform"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; @@ -37,17 +39,17 @@ stdenv.mkDerivation rec { '' + # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. - (if stdenv.isLinux then '' + stdenv.lib.optionalString stdenv.hostPlatform.isLinux '' find . -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ - --set-rpath "${lib.makeLibraryPath [ libedit ncurses5 gmp ]}" {} \; + --set-rpath "${stdenv.lib.makeLibraryPath [ libedit ncurses5 gmp ]}" {} \; for prog in ld ar gcc strip ranlib; do find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; done - '' else ""); + ''; configurePhase = '' - ./configure --prefix=$out --with-gmp-libraries=${lib.getLib gmp}/lib --with-gmp-includes=${lib.getDev gmp}/include + ./configure --prefix=$out --with-gmp-libraries=${stdenv.lib.getLib gmp}/lib --with-gmp-includes=${stdenv.lib.getDev gmp}/include ''; # Stripping combined with patchelf breaks the executables (they die diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix index a53098937ce8..2f758c47466e 100644 --- a/pkgs/development/compilers/ghc/7.0.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix @@ -1,32 +1,32 @@ -{stdenv, fetchurl, perl, ncurses5, gmp, libiconv}: +{ stdenv +, fetchurl, perl +, ncurses5, gmp, libiconv +}: stdenv.mkDerivation rec { version = "7.0.4"; name = "ghc-${version}-binary"; - src = - if stdenv.system == "i686-linux" then - fetchurl { + src = fetchurl ({ + "i686-linux" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { + }; + "x86_64-linux" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99"; - } - else if stdenv.system == "i686-darwin" then - fetchurl { + }; + "i686-darwin" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3"; - } - else if stdenv.system == "x86_64-darwin" then - fetchurl { + }; + "x86_64-darwin" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l"; - } - else throw "cannot bootstrap GHC on this platform"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index cfbc1e8dd170..60c00c2f7f53 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -1,32 +1,32 @@ -{stdenv, fetchurl, perl, ncurses5, gmp, libiconv, makeWrapper}: +{ stdenv +, fetchurl, perl, makeWrapper +, ncurses5, gmp, libiconv +}: stdenv.mkDerivation rec { version = "7.4.2"; name = "ghc-${version}-binary"; - src = - if stdenv.system == "i686-linux" then - fetchurl { + src = fetchurl ({ + "i686-linux" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { + }; + "x86_64-linux" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns"; - } - else if stdenv.system == "i686-darwin" then - fetchurl { + }; + "i686-darwin" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0"; - } - else if stdenv.system == "x86_64-darwin" then - fetchurl { + }; + "x86_64-darwin" = { url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf"; - } - else throw "cannot bootstrap GHC on this platform"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; From 2d521567933718dee4f820efb3b41a2baaf08d02 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 22 Sep 2017 13:45:31 -0400 Subject: [PATCH 4/9] ghc prebuilt: Fix indentation Doing this separately so the other commits are more readable --- .../compilers/ghc/6.10.2-binary.nix | 59 +++++----- .../compilers/ghc/7.0.4-binary.nix | 101 +++++++++--------- .../compilers/ghc/7.4.2-binary.nix | 76 ++++++------- 3 files changed, 117 insertions(+), 119 deletions(-) diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix index 99e54ff5f673..84250c1a6d33 100644 --- a/pkgs/development/compilers/ghc/6.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix @@ -9,18 +9,18 @@ stdenv.mkDerivation rec { name = "ghc-${version}-binary"; src = fetchurl ({ - "i686-linux" = { - # This binary requires libedit.so.0 (rather than libedit.so.2). - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; - sha256 = "1fw0zr2qshlpk8s0d16k27zcv5263nqdg2xds5ymw8ff6qz9rz9b"; - }; - "x86_64-linux" = { - # Idem. - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; - sha256 = "1rd2j7lmcfsm2rdfb5g6q0l8dz3sxadk5m3d2f69d4a6g4p4h7jj"; - }; - }.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform")); + "i686-linux" = { + # This binary requires libedit.so.0 (rather than libedit.so.2). + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; + sha256 = "1fw0zr2qshlpk8s0d16k27zcv5263nqdg2xds5ymw8ff6qz9rz9b"; + }; + "x86_64-linux" = { + # Idem. + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; + sha256 = "1rd2j7lmcfsm2rdfb5g6q0l8dz3sxadk5m3d2f69d4a6g4p4h7jj"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; @@ -29,14 +29,14 @@ stdenv.mkDerivation rec { # first. The GHC Cabal build system makes use of strip by default and # has hardcoded paths to /usr/bin/strip in many places. We replace # those below, making them point to our dummy script. - '' + '' mkdir "$TMP/bin" for i in strip; do echo '#! ${stdenv.shell}' > "$TMP/bin/$i" chmod +x "$TMP/bin/$i" done PATH="$TMP/bin:$PATH" - '' + + '' + # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. stdenv.lib.optionalString stdenv.hostPlatform.isLinux '' @@ -46,7 +46,7 @@ stdenv.mkDerivation rec { for prog in ld ar gcc strip ranlib; do find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; done - ''; + ''; configurePhase = '' ./configure --prefix=$out --with-gmp-libraries=${stdenv.lib.getLib gmp}/lib --with-gmp-includes=${stdenv.lib.getDev gmp}/include @@ -60,22 +60,21 @@ stdenv.mkDerivation rec { # calls install-strip ... dontBuild = true; - postInstall = - '' - # bah, the passing gmp doesn't work, so let's add it to the final package.conf in a quick but dirty way - sed -i "s@^\(.*pkgName = PackageName \"rts\".*\libraryDirs = \\[\)\(.*\)@\\1\"${gmp.out}/lib\",\2@" $out/lib/ghc-${version}/package.conf + postInstall = '' + # bah, the passing gmp doesn't work, so let's add it to the final package.conf in a quick but dirty way + sed -i "s@^\(.*pkgName = PackageName \"rts\".*\libraryDirs = \\[\)\(.*\)@\\1\"${gmp.out}/lib\",\2@" $out/lib/ghc-${version}/package.conf - # Sanity check, can ghc create executables? - cd $TMP - mkdir test-ghc; cd test-ghc - cat > main.hs << EOF - module Main where - main = putStrLn "yes" - EOF - $out/bin/ghc --make main.hs - echo compilation ok - [ $(./main) == "yes" ] - ''; + # Sanity check, can ghc create executables? + cd $TMP + mkdir test-ghc; cd test-ghc + cat > main.hs << EOF + module Main where + main = putStrLn "yes" + EOF + $out/bin/ghc --make main.hs + echo compilation ok + [ $(./main) == "yes" ] + ''; meta = { homepage = http://haskell.org/ghc; diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix index 2f758c47466e..394e4239e9a0 100644 --- a/pkgs/development/compilers/ghc/7.0.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix @@ -9,24 +9,24 @@ stdenv.mkDerivation rec { name = "ghc-${version}-binary"; src = fetchurl ({ - "i686-linux" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; - sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63"; - }; - "x86_64-linux" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; - sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99"; - }; - "i686-darwin" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; - sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3"; - }; - "x86_64-darwin" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; - sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l"; - }; - }.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform")); + "i686-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; + sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63"; + }; + "x86_64-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; + sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99"; + }; + "i686-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; + sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3"; + }; + "x86_64-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; + sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; @@ -41,22 +41,22 @@ stdenv.mkDerivation rec { # first. The GHC Cabal build system makes use of strip by default and # has hardcoded paths to /usr/bin/strip in many places. We replace # those below, making them point to our dummy script. - '' + '' mkdir "$TMP/bin" for i in strip; do echo '#! ${stdenv.shell}' > "$TMP/bin/$i" chmod +x "$TMP/bin/$i" done PATH="$TMP/bin:$PATH" - '' + + '' + # We have to patch the GMP paths for the integer-gmp package. - '' + '' find . -name integer-gmp.buildinfo \ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; - '' + stdenv.lib.optionalString stdenv.isDarwin '' + '' + stdenv.lib.optionalString stdenv.isDarwin '' find . -name base.buildinfo \ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \; - '' + + '' + # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. stdenv.lib.optionalString stdenv.isLinux '' @@ -68,24 +68,24 @@ stdenv.mkDerivation rec { for prog in ld ar gcc strip ranlib; do find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; done - '' + stdenv.lib.optionalString stdenv.isDarwin '' - # not enough room in the object files for the full path to libiconv :( - fix () { - install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 - } + '' + stdenv.lib.optionalString stdenv.isDarwin '' + # not enough room in the object files for the full path to libiconv :( + fix () { + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 + } - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp - for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do - fix $(find . -type f -name $file) - done + for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do + fix $(find . -type f -name $file) + done - for file in $(find . -name setup-config); do - substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" - done - ''; + for file in $(find . -name setup-config); do + substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" + done + ''; configurePhase = '' ./configure --prefix=$out \ @@ -101,19 +101,18 @@ stdenv.mkDerivation rec { # calls install-strip ... dontBuild = true; - postInstall = - '' - # Sanity check, can ghc create executables? - cd $TMP - mkdir test-ghc; cd test-ghc - cat > main.hs << EOF - module Main where - main = putStrLn "yes" - EOF - $out/bin/ghc --make main.hs - echo compilation ok - [ $(./main) == "yes" ] - ''; + postInstall = '' + # Sanity check, can ghc create executables? + cd $TMP + mkdir test-ghc; cd test-ghc + cat > main.hs << EOF + module Main where + main = putStrLn "yes" + EOF + $out/bin/ghc --make main.hs + echo compilation ok + [ $(./main) == "yes" ] + ''; meta.license = stdenv.lib.licenses.bsd3; meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index 60c00c2f7f53..9d85253f6309 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -9,24 +9,24 @@ stdenv.mkDerivation rec { name = "ghc-${version}-binary"; src = fetchurl ({ - "i686-linux" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; - sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi"; - }; - "x86_64-linux" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; - sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns"; - }; - "i686-darwin" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; - sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0"; - }; - "x86_64-darwin" = { - url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; - sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf"; - }; - }.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform")); + "i686-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; + sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi"; + }; + "x86_64-linux" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; + sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns"; + }; + "i686-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; + sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0"; + }; + "x86_64-darwin" = { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; + sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf"; + }; + }.${stdenv.hostPlatform.system} + or (throw "cannot bootstrap GHC on this platform")); buildInputs = [perl]; @@ -41,22 +41,22 @@ stdenv.mkDerivation rec { # first. The GHC Cabal build system makes use of strip by default and # has hardcoded paths to /usr/bin/strip in many places. We replace # those below, making them point to our dummy script. - '' + '' mkdir "$TMP/bin" for i in strip; do echo '#! ${stdenv.shell}' > "$TMP/bin/$i" chmod +x "$TMP/bin/$i" done PATH="$TMP/bin:$PATH" - '' + + '' + # We have to patch the GMP paths for the integer-gmp package. - '' + '' find . -name integer-gmp.buildinfo \ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; - '' + stdenv.lib.optionalString stdenv.isDarwin '' + '' + stdenv.lib.optionalString stdenv.isDarwin '' find . -name base.buildinfo \ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \; - '' + + '' + # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. stdenv.lib.optionalString stdenv.isLinux '' @@ -73,24 +73,24 @@ stdenv.mkDerivation rec { for prog in ld ar gcc strip ranlib; do find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; done - '' + stdenv.lib.optionalString stdenv.isDarwin '' - # not enough room in the object files for the full path to libiconv :( - fix () { - install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 - } + '' + stdenv.lib.optionalString stdenv.isDarwin '' + # not enough room in the object files for the full path to libiconv :( + fix () { + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $1 + } - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist-install/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist-install/build/tmp - ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/ghc-pwd/dist-install/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/utils/hpc/dist-install/build/tmp + ln -s ${libiconv}/lib/libiconv.dylib ghc-${version}/ghc/stage2/build/tmp - for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do - fix $(find . -type f -name $file) - done + for file in ghc-cabal ghc-pwd ghc-stage2 ghc-pkg haddock hsc2hs hpc; do + fix $(find . -type f -name $file) + done - for file in $(find . -name setup-config); do - substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" - done - ''; + for file in $(find . -name setup-config); do + substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" + done + ''; configurePhase = '' ./configure --prefix=$out \ From bc0aec5d974a6a3269aeb4cec582e51baa433853 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 20 Sep 2017 11:33:29 -0400 Subject: [PATCH 5/9] doc: Document forthcomming NIX_DEBUG degredations --- doc/stdenv.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/stdenv.xml b/doc/stdenv.xml index dac53bc2b800..a097762130a5 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -1,4 +1,3 @@ - @@ -188,11 +187,13 @@ genericBuild NIX_DEBUG - If set, stdenv will print some - debug information during the build. In particular, the - gcc and ld wrapper scripts - will print out the complete command line passed to the wrapped - tools. + + A natural number indicating how much information to log. + If set to 1 or higher, stdenv will print moderate debug information during the build. + In particular, the gcc and ld wrapper scripts will print out the complete command line passed to the wrapped tools. + If set to 6 or higher, the stdenv setup script will be run with set -x tracing. + If set to 7 or higher, the gcc and ld wrapper scripts will also be run with set -x tracing. + From 127a5f3357eeebc4797fdce66b99b02b831a3a3f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 19 Sep 2017 19:10:49 -0400 Subject: [PATCH 6/9] treewide: Use `(( "${NIX_DEBUG:-0}" >= 1) ))` consistently --- .../build-support/cc-wrapper/add-hardening.sh | 22 +++++++++---------- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 2 +- pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 2 +- .../cc-wrapper/gnatlink-wrapper.sh | 2 +- pkgs/build-support/cc-wrapper/ld-wrapper.sh | 2 +- pkgs/build-support/cc-wrapper/utils.sh | 2 +- pkgs/stdenv/generic/setup.sh | 6 ++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/add-hardening.sh b/pkgs/build-support/cc-wrapper/add-hardening.sh index 34358e04194a..b0e39e455ffc 100644 --- a/pkgs/build-support/cc-wrapper/add-hardening.sh +++ b/pkgs/build-support/cc-wrapper/add-hardening.sh @@ -16,14 +16,14 @@ do hardeningDisableMap[$flag]=1 done -if [[ -n "${NIX_DEBUG:-}" ]]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then printf 'HARDENING: disabled flags:' >&2 (( "${#hardeningDisableMap[@]}" )) && printf ' %q' "${!hardeningDisableMap[@]}" >&2 echo >&2 fi if [[ -z "${hardeningDisableMap[all]:-}" ]]; then - if [[ -n "${NIX_DEBUG:-}" ]]; then + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo 'HARDENING: Is active (not completely disabled with "all" flag)' >&2; fi for flag in "${hardeningFlags[@]}" @@ -31,40 +31,40 @@ if [[ -z "${hardeningDisableMap[all]:-}" ]]; then if [[ -z "${hardeningDisableMap[$flag]:-}" ]]; then case $flag in fortify) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling fortify >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling fortify >&2; fi hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2') ;; stackprotector) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling stackprotector >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling stackprotector >&2; fi hardeningCFlags+=('-fstack-protector-strong' '--param' 'ssp-buffer-size=4') ;; pie) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling CFlags -fPIE >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling CFlags -fPIE >&2; fi hardeningCFlags+=('-fPIE') if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi hardeningCFlags+=('-pie') hardeningLDFlags+=('-pie') fi ;; pic) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling pic >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling pic >&2; fi hardeningCFlags+=('-fPIC') ;; strictoverflow) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling strictoverflow >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling strictoverflow >&2; fi hardeningCFlags+=('-fno-strict-overflow') ;; format) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling format >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling format >&2; fi hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security') ;; relro) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling relro >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling relro >&2; fi hardeningLDFlags+=('-z' 'relro') ;; bindnow) - if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling bindnow >&2; fi + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling bindnow >&2; fi hardeningLDFlags+=('-z' 'now') ;; *) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index aacaf196f313..f5bcfc9f9851 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -161,7 +161,7 @@ if [ "$*" = -v ]; then fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then # Old bash workaround, see ld-wrapper for explanation. echo "extra flags before to @prog@:" >&2 printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh index f0c922a3d5b4..42df660211b9 100644 --- a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -109,7 +109,7 @@ fi #fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "extra flags before to @prog@:" >&2 printf " %q\n" "${extraBefore[@]}" >&2 echo "original flags to @prog@:" >&2 diff --git a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh index 2de748b5f31e..b0615731b282 100644 --- a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh @@ -24,7 +24,7 @@ extraBefore=() #export NIX_@infixSalt@_LDFLAGS_SET=1 # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "extra flags before to @prog@:" >&2 printf " %q\n" "${extraBefore[@]}" >&2 echo "original flags to @prog@:" >&2 diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index a9cc1e3f9e6f..a849df86ef0e 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -156,7 +156,7 @@ fi # Optionally print debug info. -if [ -n "${NIX_DEBUG:-}" ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then # Old bash workaround, see above. echo "extra flags before to @prog@:" >&2 printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh index c84a094e26b0..c43c2e12d74a 100644 --- a/pkgs/build-support/cc-wrapper/utils.sh +++ b/pkgs/build-support/cc-wrapper/utils.sh @@ -1,5 +1,5 @@ skip () { - if [ -n "${NIX_DEBUG:-}" ]; then + if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "skipping impure path $1" >&2 fi } diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index ce8c3ecef829..524caafc8720 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -269,7 +269,7 @@ for i in $initialPath; do addToSearchPath PATH "$i/bin" done -if [ "${NIX_DEBUG:-}" = 1 ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "initial path: $PATH" fi @@ -429,7 +429,7 @@ fi PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH" -if [ "${NIX_DEBUG:-}" = 1 ]; then +if (( "${NIX_DEBUG:-0}" >= 1 )); then echo "final path: $PATH" fi @@ -539,7 +539,7 @@ substituteAll() { local -a args=() for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do - if [ "${NIX_DEBUG:-}" = "1" ]; then + if (( "${NIX_DEBUG:-0}" >= 1 )); then printf "@%s@ -> %q\n" "${varName}" "${!varName}" fi args+=("--subst-var" "$varName") From f6fcb9bc0d33e59b09d1b4b9e15d83260954f850 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 19 Sep 2017 19:11:29 -0400 Subject: [PATCH 7/9] stdenv: Turn on `set -x` if NIX_DEBUG >= 6 Why 6? It seems a decently high number, giving us room for more degrees of debugging before the `set -x` sledgehammer without incurring a mass-rebuild. --- pkgs/stdenv/generic/setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 524caafc8720..02da3829c5ae 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -1,6 +1,10 @@ set -eu set -o pipefail +if (( "${NIX_DEBUG:-0}" >= 6 )); then + set -x +fi + : ${outputs:=out} From 0d3d2a01d20d88dde3696ead43c557c1f3043ee7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 20 Sep 2017 11:35:58 -0400 Subject: [PATCH 8/9] cc-wrapper: Add `set -x` tracing for NIX_DEBUG >= 7 --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 4 ++++ pkgs/build-support/cc-wrapper/gnat-wrapper.sh | 4 ++++ pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh | 4 ++++ pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh | 4 ++++ pkgs/build-support/cc-wrapper/ld-wrapper.sh | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index f5bcfc9f9851..e6f5a5a9f7d8 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + path_backup="$PATH" # That @-vars are substituted separately from bash evaluation makes diff --git a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh index 42df660211b9..b15f1e461e5f 100644 --- a/pkgs/build-support/cc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnat-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + # N.B. Gnat is not used during bootstrapping, so we don't need to # worry about the old bash empty array `set -u` workarounds. diff --git a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh index b0615731b282..88e644dc54dc 100644 --- a/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/gnatlink-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + # N.B. Gnat is not used during bootstrapping, so we don't need to # worry about the old bash empty array `set -u` workarounds. diff --git a/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh index 72c999ff8bc8..5d81e34a047f 100755 --- a/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-solaris-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + declare -a args=("$@") # I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( # Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index a849df86ef0e..355ea8818981 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -2,6 +2,10 @@ set -eu -o pipefail shopt -s nullglob +if (( "${NIX_DEBUG:-0}" >= 7 )); then + set -x +fi + path_backup="$PATH" # phase separation makes this look useless From d349f9a34006cc484b5e7509a3f227d52d6e2a5d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 20 Sep 2017 11:07:52 -0400 Subject: [PATCH 9/9] cc-wrapper: Use stdenvNoCC to build cc-wrapper may wrap a cc-compiler, but it doesn't need one to build itself. (c.f. expand-response-params is a separate derivation.) This helps avoid cycles on the cross stuff, in addition to removing a useless dependency edge. I could have been super careful with overrides in the stdenv to avoid the mass rebuild, but I don't think it's worth it. --- pkgs/build-support/cc-wrapper/default.nix | 7 ++++--- pkgs/stdenv/darwin/default.nix | 4 ++-- pkgs/stdenv/freebsd/default.nix | 2 +- pkgs/stdenv/linux/default.nix | 4 ++-- pkgs/stdenv/native/default.nix | 3 ++- pkgs/stdenv/nix/default.nix | 13 +++++-------- pkgs/top-level/all-packages.nix | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 866be9cded9e..489fb02dcb5d 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -5,15 +5,15 @@ # script that sets up the right environment variables so that the # compiler and the linker just "work". -{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" -, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell +{ name ? "", stdenvNoCC, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" +, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenvNoCC.shell , zlib ? null, extraPackages ? [], extraBuildCommands ? "" , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , buildPackages ? {} , useMacosReexportHack ? false }: -with stdenv.lib; +with stdenvNoCC.lib; assert nativeTools -> nativePrefix != ""; assert !nativeTools -> @@ -25,6 +25,7 @@ assert (noLibc || nativeLibc) == (libc == null); assert cc.langVhdl or false -> zlib != null; let + stdenv = stdenvNoCC; inherit (stdenv) hostPlatform targetPlatform; # Prefix for binaries. Customarily ends with a dash separator. diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index b7f750508e8c..a67ca53e1c54 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -77,7 +77,7 @@ in rec { cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { inherit shell; - inherit (last) stdenv; + inherit (last) stdenvNoCC; nativeTools = false; nativeLibc = false; @@ -324,7 +324,7 @@ in rec { shell = "${pkgs.bash}/bin/bash"; cc = lib.callPackageWith {} ../../build-support/cc-wrapper { - inherit (pkgs) stdenv; + inherit (pkgs) stdenvNoCC; inherit shell; nativeTools = false; nativeLibc = false; diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix index c10d1515a3d5..6ab8bf217269 100644 --- a/pkgs/stdenv/freebsd/default.nix +++ b/pkgs/stdenv/freebsd/default.nix @@ -77,7 +77,7 @@ let inherit (localSystem) system; in nativeTools = true; nativePrefix = "/usr"; nativeLibc = true; - inherit (prevStage) stdenv; + stdenvNoCC = prevStage.stdenv; cc = { name = "clang-9.9.9"; cc = "/usr"; diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index e79ec48e9f42..a114ab609e6c 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -84,7 +84,7 @@ let libc = prevStage.glibc; inherit (prevStage) binutils coreutils gnugrep; name = name; - stdenv = prevStage.ccWrapperStdenv; + stdenvNoCC = prevStage.ccWrapperStdenv; }; extraAttrs = { @@ -244,7 +244,7 @@ in }; cc = prevStage.gcc-unwrapped; libc = self.glibc; - inherit (self) stdenv binutils coreutils gnugrep; + inherit (self) stdenvNoCC binutils coreutils gnugrep; name = ""; shell = self.bash + "/bin/bash"; }; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 9ecb56028bc0..558a77281edb 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -117,6 +117,7 @@ in cc = null; fetchurl = null; }; + stdenvNoCC = stdenv; cc = import ../../build-support/cc-wrapper { name = "cc-native"; @@ -126,7 +127,7 @@ in "i686-solaris" = "/usr/gnu"; "x86_64-solaris" = "/opt/local/gcc47"; }.${system} or "/usr"; - inherit stdenv; + inherit stdenvNoCC; }; fetchurl = import ../../build-support/fetchurl { diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index c736442dc0a4..ffff8bdf51d4 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -1,5 +1,5 @@ { lib -, crossSystem, config +, crossSystem, config, overlays , bootStages , ... }: @@ -7,9 +7,7 @@ assert crossSystem == null; bootStages ++ [ - (prevStage: let - inherit (prevStage) stdenv; - in { + (prevStage: { inherit config overlays; stdenv = import ../generic rec { @@ -27,10 +25,9 @@ bootStages ++ [ cc = import ../../build-support/cc-wrapper { nativeTools = false; - nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr"; + nativePrefix = lib.optionalString hostPlatform.isSunOS "/usr"; nativeLibc = true; - inherit stdenv; - inherit (prevStage) binutils coreutils gnugrep; + inherit (prevStage) stdenvNoCC binutils coreutils gnugrep; cc = prevStage.gcc.cc; isGNU = true; shell = prevStage.bash + "/bin/sh"; @@ -38,7 +35,7 @@ bootStages ++ [ shell = prevStage.bash + "/bin/sh"; - fetchurlBoot = stdenv.fetchurlBoot; + fetchurlBoot = prevStage.stdenv.fetchurlBoot; overrides = self: super: { inherit cc; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 860567283b86..94aebfe7fb7b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6207,11 +6207,11 @@ with pkgs; wla-dx = callPackage ../development/compilers/wla-dx { }; - wrapCCWith = { name ? "", cc, libc, extraBuildCommands ? "" }: ccWrapperFun { + wrapCCWith = { name ? "", cc, libc, extraBuildCommands ? "" }: ccWrapperFun rec { nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false; nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false; nativePrefix = stdenv.cc.nativePrefix or ""; - noLibc = (libc == null); + noLibc = !nativeLibc && (libc == null); isGNU = cc.isGNU or false; isClang = cc.isClang or false;