From 63bd851e9554cdb1bd703a461443723fd057933d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 24 Nov 2019 23:07:20 +0000 Subject: [PATCH 01/14] stdenv: Introduce hasCC attribute Before, we'd always use `cc = null`, and check for that. The problem is this breaks for cross compilation to platforms that don't support a C compiler. It's a very subtle issue. One might think there is no problem because we have `stdenvNoCC`, and presumably one would only build derivations that use that. The problem is that one still wants to use tools at build-time that are themselves built with a C compiler, and those are gotten via "splicing". The runtime version of those deps will explode, but the build time / `buildPackages` versions of those deps will be fine, and splicing attempts to work this by using `builtins.tryEval` to filter out any broken "higher priority" packages (runtime is the default and highest priority) so that both `foo` and `foo.nativeDrv` works. However, `tryEval` only catches certain evaluation failures (e.g. exceptions), and not arbitrary failures (such as `cc.attr` when `cc` is null). This means `tryEval` fails to let us use our build time deps, and everything comes apart. The right solution is, as usually, to get rid of splicing. Or, baring that, to make it so `foo` never works and one has to explicitly do `foo.*`. But that is a much larger change, and certaily one unsuitable to be backported to stable. Given that, we instead make an exception-throwing `cc` attribute, and create a `hasCC` attribute for those derivations which wish to condtionally use a C compiler: instead of doing `stdenv.cc or null == null` or something similar, one does `stdenv.hasCC`. This allows quering without "tripping" the exception, while also allowing `tryEval` to work. No platform without a C compiler is yet wired up by default. That will be done in a following commit. --- pkgs/build-support/bintools-wrapper/default.nix | 2 +- pkgs/build-support/cc-wrapper/default.nix | 2 +- pkgs/development/interpreters/perl/default.nix | 2 +- pkgs/stdenv/generic/default.nix | 16 +++++++++++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 5dddbde9eec..648b8b4ffa9 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -66,7 +66,7 @@ let else null; expand-response-params = - if buildPackages.stdenv.cc or null != null && buildPackages.stdenv.cc != "/dev/null" + if buildPackages ? stdenv && buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null" then import ../expand-response-params { inherit (buildPackages) stdenv; } else ""; diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 9851602179c..a4ece85e619 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -59,7 +59,7 @@ let infixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config; expand-response-params = - if buildPackages.stdenv.cc or null != null && buildPackages.stdenv.cc != "/dev/null" + if buildPackages.stdenv.hasCC && buildPackages.stdenv.cc != "/dev/null" then import ../expand-response-params { inherit (buildPackages) stdenv; } else ""; diff --git a/pkgs/development/interpreters/perl/default.nix b/pkgs/development/interpreters/perl/default.nix index 2ecc5cbb2ef..5ad19ce9f3d 100644 --- a/pkgs/development/interpreters/perl/default.nix +++ b/pkgs/development/interpreters/perl/default.nix @@ -136,7 +136,7 @@ let substituteInPlace "$out"/lib/perl5/*/*/Config_heavy.pl \ --replace "${libcInc}" /no-such-path \ --replace "${ - if stdenv.cc.cc or null != null then stdenv.cc.cc else "/no-such-path" + if stdenv.hasCC then stdenv.cc.cc else "/no-such-path" }" /no-such-path \ --replace "${stdenv.cc}" /no-such-path \ --replace "$man" /no-such-path diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 2f43db9cfc2..befeb450997 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -1,6 +1,15 @@ let lib = import ../../../lib; in lib.makeOverridable ( -{ name ? "stdenv", preHook ? "", initialPath, cc, shell +{ name ? "stdenv", preHook ? "", initialPath + +, # If we don't have a C compiler, we might either have `cc = null` or `cc = + # throw ...`, but if we do have a C compiler we should definiely have `cc != + # null`. + # + # TODO(@Ericson2314): Add assert without creating infinite recursion + hasCC ? cc != null, cc + +, shell , allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config , # The `fetchurl' to use for downloading curl and its dependencies @@ -57,7 +66,8 @@ let ../../build-support/setup-hooks/move-sbin.sh ../../build-support/setup-hooks/move-lib64.sh ../../build-support/setup-hooks/set-source-date-epoch-to-latest.sh - cc + # TODO use lib.optional instead + (if hasCC then cc else null) ]; defaultBuildInputs = extraBuildInputs; @@ -145,7 +155,7 @@ let inherit overrides; - inherit cc; + inherit cc hasCC; } # Propagate any extra attributes. For instance, we use this to From c739c420db5b9d56c335414be1696c57f2dbbb6a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 24 Nov 2019 23:07:20 +0000 Subject: [PATCH 02/14] Add support for cross compiling to `js-ghcjs` This platform doesn't have a C compiler, and so relies and the changes in the previous commit to work. --- lib/systems/doubles.nix | 2 ++ pkgs/stdenv/booter.nix | 9 ++++++--- pkgs/stdenv/cross/default.nix | 8 +++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index 58cff18e648..f07e9da33bc 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -27,6 +27,8 @@ let "riscv32-linux" "riscv64-linux" "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" + + "js-ghcjs" ]; allParsed = map parse.mkSystemFromString all; diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 1df05099fbf..8a574652204 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -121,9 +121,12 @@ stageFuns: let postStage = buildPackages: { __raw = true; stdenv.cc = - if buildPackages.stdenv.cc.isClang or false - then buildPackages.clang - else buildPackages.gcc; + if buildPackages.stdenv.hasCC + then + if buildPackages.stdenv.cc.isClang or false + then buildPackages.clang + else buildPackages.gcc + else buildPackages.stdenv.cc; }; in dfold folder postStage (_: {}) withAllowCustomOverrides diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 4e5c4cc2e83..44d412e041b 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -51,12 +51,18 @@ in lib.init bootStages ++ [ extraBuildInputs = [ ]; # Old ones run on wrong platform allowedRequisites = null; + hasCC = !targetPlatform.isGhcjs; + cc = if crossSystem.useiOSPrebuilt or false then buildPackages.darwin.iosSdkPkgs.clang else if crossSystem.useAndroidPrebuilt or false then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang else if targetPlatform.isGhcjs - then null + # Need to use `throw` so tryEval for splicing works, ugh. Using + # `null` or skipping the attribute would cause an eval failure + # `tryEval` wouldn't catch, wrecking accessing previous stages + # when there is a C compiler and everything should be fine. + then throw "no C compile provided for this platform" else if crossSystem.useLLVM or false then buildPackages.llvmPackages_8.lldClang else buildPackages.gcc; From ea9a2c5ec21bf088bbdef036238fa67cdc85b073 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 24 Nov 2019 23:07:20 +0000 Subject: [PATCH 03/14] haskell genenric-builder: Make the C compiler optional This is GHCJS, and perhaps other obscure targets. --- pkgs/development/haskell-modules/generic-builder.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 87d3b5ae496..d6966d69136 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -40,7 +40,7 @@ in # They must be propagated to the environment of any executable linking with the library , libraryFrameworkDepends ? [], executableFrameworkDepends ? [] , homepage ? "https://hackage.haskell.org/package/${pname}" -, platforms ? with stdenv.lib.platforms; unix ++ windows # GHC can cross-compile +, platforms ? with stdenv.lib.platforms; all # GHC can cross-compile , hydraPlatforms ? null , hyperlinkSource ? true , isExecutable ? false, isLibrary ? !isExecutable @@ -133,6 +133,7 @@ let crossCabalFlags = [ "--with-ghc=${ghc.targetPrefix}ghc" "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg" + ] ++ optionals stdenv.hasCC [ "--with-gcc=${stdenv.cc.targetPrefix}cc" "--with-ld=${stdenv.cc.bintools.targetPrefix}ld" "--with-ar=${stdenv.cc.bintools.targetPrefix}ar" @@ -156,7 +157,9 @@ let "--libsubdir=\\$abi/\\$libname" (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}") + ] ++ optionals stdenv.hasCC [ "--with-gcc=$CC" # Clang won't work without that extra information. + ] ++ [ "--package-db=$packageConfDir" (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names") From 765d2608b694e425743b8030570ea8c99e167558 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 25 Nov 2019 14:09:50 +0000 Subject: [PATCH 04/14] Fix lib tests js-ghcjs didn't fit in an existing categor. --- lib/systems/doubles.nix | 1 + lib/tests/systems.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index f07e9da33bc..2e3e3b9223f 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -47,6 +47,7 @@ in { x86_64 = filterDoubles predicates.isx86_64; mips = filterDoubles predicates.isMips; riscv = filterDoubles predicates.isRiscV; + js = filterDoubles predicates.isJavaScript; cygwin = filterDoubles predicates.isCygwin; darwin = filterDoubles predicates.isDarwin; diff --git a/lib/tests/systems.nix b/lib/tests/systems.nix index 818749442f9..6f52912994d 100644 --- a/lib/tests/systems.nix +++ b/lib/tests/systems.nix @@ -12,7 +12,7 @@ let expected = lib.sort lib.lessThan y; }; in with lib.systems.doubles; lib.runTests { - testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded); + testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js); testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ]; testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" "i686-none" "i686-darwin" ]; From 87379637357f362abe47cc8a86fd7f2735f6180a Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 25 Nov 2019 14:09:50 +0000 Subject: [PATCH 05/14] Fix lib tests js-ghcjs didn't fit in an existing categor. --- pkgs/stdenv/cross/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 44d412e041b..cc49af7de3b 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -62,7 +62,7 @@ in lib.init bootStages ++ [ # `null` or skipping the attribute would cause an eval failure # `tryEval` wouldn't catch, wrecking accessing previous stages # when there is a C compiler and everything should be fine. - then throw "no C compile provided for this platform" + then throw "no C compiler provided for this platform" else if crossSystem.useLLVM or false then buildPackages.llvmPackages_8.lldClang else buildPackages.gcc; From d3ecd5bde5682b62728101a3026875aabeb1886d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Dec 2019 17:54:04 -0500 Subject: [PATCH 06/14] release-cross.nix: Add GHCJS-built hello --- pkgs/top-level/release-cross.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix index bc822b466c9..4c0612a5e7e 100644 --- a/pkgs/top-level/release-cross.nix +++ b/pkgs/top-level/release-cross.nix @@ -135,6 +135,11 @@ in /* Linux on the fuloong */ fuloongminipc = mapTestOnCross lib.systems.examples.fuloongminipc linuxCommon; + /* Javacript */ + ghcjs = mapTestOnCross lib.systems.examples.ghcjs { + haskell.packages.ghcjs.hello = nativePlatforms; + }; + /* Linux on Raspberrypi */ rpi = mapTestOnCross lib.systems.examples.raspberryPi rpiCommon; rpi-musl = mapTestOnCross lib.systems.examples.muslpi rpiCommon; From ad93663a485afe830b3d1edb27ae3d3471e6cf99 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Dec 2019 18:17:41 -0500 Subject: [PATCH 07/14] ghcWithHoogle: Fix for cross Use `buildPackages.stdenv.mkDerivation` because we are making a shell script to start hoogle on the build platform. --- pkgs/development/haskell-modules/hoogle.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/hoogle.nix b/pkgs/development/haskell-modules/hoogle.nix index 0bb930a8bb3..0f620d46ccc 100644 --- a/pkgs/development/haskell-modules/hoogle.nix +++ b/pkgs/development/haskell-modules/hoogle.nix @@ -23,7 +23,8 @@ # This will build mmorph and monadControl, and have the hoogle installation # refer to their documentation via symlink so they are not garbage collected. -{ lib, stdenv, hoogle, writeText, ghc +{ lib, stdenv, buildPackages +, hoogle, writeText, ghc , packages }: @@ -53,7 +54,7 @@ let (map (lib.getOutput "doc") packages); in -stdenv.mkDerivation { +buildPackages.stdenv.mkDerivation { name = "hoogle-local-0.1"; buildInputs = [ghc hoogle]; From c3c245dcda8cc54055bca7fe08c59dd1d3a41408 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Dec 2019 19:49:48 -0500 Subject: [PATCH 08/14] ghcjs: get socket.io from pkgsHostHost This is a bit dubvious, but the alternative of making nodejs a nativeBuildInput for node packages is worse. In general the cross story for interpreted languages is murky, and this fits that pattern. --- pkgs/development/compilers/ghcjs-ng/default.nix | 4 ++-- pkgs/development/compilers/ghcjs/base.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghcjs-ng/default.nix b/pkgs/development/compilers/ghcjs-ng/default.nix index 068d7b578df..ba25458d79a 100644 --- a/pkgs/development/compilers/ghcjs-ng/default.nix +++ b/pkgs/development/compilers/ghcjs-ng/default.nix @@ -1,4 +1,5 @@ { stdenv +, pkgsHostHost , callPackage , fetchgit , ghcjsSrcJson ? null @@ -14,7 +15,6 @@ , pkgconfig , gcc , lib -, nodePackages , ghcjsDepOverrides ? (_:_:{}) , haskell }: @@ -47,7 +47,7 @@ let enableShared = true; - socket-io = nodePackages."socket.io"; + socket-io = pkgsHostHost.nodePackages."socket.io"; # Relics of the old GHCJS build system stage1Packages = []; diff --git a/pkgs/development/compilers/ghcjs/base.nix b/pkgs/development/compilers/ghcjs/base.nix index ba0bbb1962b..533f2a17ada 100644 --- a/pkgs/development/compilers/ghcjs/base.nix +++ b/pkgs/development/compilers/ghcjs/base.nix @@ -33,7 +33,7 @@ , alex, happy, git, gnumake, autoconf, patch , automake, libtool , cryptohash -, haddock, hspec, xhtml, pkgs +, haddock, hspec, xhtml, pkgs, pkgsHostHost , coreutils , libiconv @@ -137,7 +137,7 @@ in mkDerivation ({ isCross = true; isGhcjs = true; inherit nodejs ghcjsBoot; - socket-io = pkgs.nodePackages."socket.io"; + socket-io = pkgsHostHost.nodePackages."socket.io"; haskellCompilerName = "ghcjs-${version}"; # let us assume ghcjs is never actually cross compiled From 95464f6ad3cb64bcc56b4761cfcb4261944679e9 Mon Sep 17 00:00:00 2001 From: John Cotton Ericson Date: Wed, 25 Dec 2019 01:21:34 -0500 Subject: [PATCH 09/14] treewide: Check `stdenv.isi686` before checking `stdenv.cc.isGNU` This makes us a bit more robust to various splicing nastiness. May splicing someday go so we don't have to resort to such hacks. --- pkgs/top-level/all-packages.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9b9277c78a8..db8a92321ea 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8138,7 +8138,7 @@ in llvmPackages_35 = callPackage ../development/compilers/llvm/3.5 ({ isl = isl_0_14; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; }); @@ -8146,7 +8146,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_39.tools; targetLlvmLibraries = targetPackages.llvmPackages_39.libraries; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; }); @@ -8154,7 +8154,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_4.tools; targetLlvmLibraries = targetPackages.llvmPackages_4.libraries; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; }); @@ -8162,7 +8162,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_5.tools; targetLlvmLibraries = targetPackages.llvmPackages_5.libraries; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' }); @@ -8170,7 +8170,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_6.tools; targetLlvmLibraries = targetPackages.llvmPackages_6.libraries; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { # with gcc-7 on i686: undefined reference to `__divmoddi4' # Failing tests with gcc8. stdenv = overrideCC stdenv (if stdenv.hostPlatform.isi686 then gcc6 else gcc7); @@ -8180,7 +8180,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_7.tools; targetLlvmLibraries = targetPackages.llvmPackages_7.libraries; - } // stdenv.lib.optionalAttrs (buildPackages.stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && buildPackages.stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' }); @@ -8188,7 +8188,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_8.tools; targetLlvmLibraries = targetPackages.llvmPackages_8.libraries; - } // stdenv.lib.optionalAttrs (buildPackages.stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && buildPackages.stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' }); @@ -8973,7 +8973,7 @@ in spidermonkey_1_8_5 = callPackage ../development/interpreters/spidermonkey/1.8.5.nix { }; spidermonkey_38 = callPackage ../development/interpreters/spidermonkey/38.nix ({ inherit (darwin) libobjc; - } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); spidermonkey_52 = callPackage ../development/interpreters/spidermonkey/52.nix { }; @@ -11347,27 +11347,27 @@ in icu58 = callPackage (import ../development/libraries/icu/58.nix fetchurl) ({ nativeBuildRoot = buildPackages.icu58.override { buildRootOnly = true; }; } // - (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); icu59 = callPackage ../development/libraries/icu/59.nix ({ nativeBuildRoot = buildPackages.icu59.override { buildRootOnly = true; }; - } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); icu60 = callPackage ../development/libraries/icu/60.nix ({ nativeBuildRoot = buildPackages.icu60.override { buildRootOnly = true; }; - } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); icu63 = callPackage ../development/libraries/icu/63.nix ({ nativeBuildRoot = buildPackages.icu63.override { buildRootOnly = true; }; - } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); icu64 = callPackage ../development/libraries/icu/64.nix ({ nativeBuildRoot = buildPackages.icu64.override { buildRootOnly = true; }; - } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // (stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' })); From 694b81fabc288c49cf2f1c29ae91f3c18def7a8d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 25 Dec 2019 01:32:00 -0500 Subject: [PATCH 10/14] arrow-cpp, llvmPackage_9: Check stdenv.isi686 before stdenv.cc.isGNU See c3c245dcda8cc54055bca7fe08c59dd1d3a41408 --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d6a7963dfee..4ba520e5f9b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8458,7 +8458,7 @@ in inherit (stdenvAdapters) overrideCC; buildLlvmTools = buildPackages.llvmPackages_9.tools; targetLlvmLibraries = targetPackages.llvmPackages_9.libraries; - } // stdenv.lib.optionalAttrs (buildPackages.stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && buildPackages.stdenv.cc.isGNU) { stdenv = gcc6Stdenv; # with gcc-7: undefined reference to `__divmoddi4' }); @@ -10653,7 +10653,7 @@ in arrow-cpp = callPackage ../development/libraries/arrow-cpp ({ gtest = gtest.override { static = true; }; - } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { + } // stdenv.lib.optionalAttrs (stdenv.hostPlatform.isi686 && stdenv.cc.isGNU) { stdenv = overrideCC stdenv buildPackages.gcc6; # hidden symbol `__divmoddi4' }); From ed6c877f143db3bbe3c17a71370a0b93b244d813 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 28 Oct 2019 14:54:37 +0000 Subject: [PATCH 11/14] symlinkJoin: fix cross (cherry picked from commit 59dbb005556e5bdc0d342ddb1f3801ebcea02413) --- pkgs/top-level/stage.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 4fe067694dc..9e07d2bf061 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -71,7 +71,7 @@ let trivialBuilders = self: super: import ../build-support/trivial-builders.nix { - inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; + inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.pkgsBuildHost.xorg) lndir; inherit (self) runtimeShell; }; From 6a23c9ddbef2bf80f28d9d2cda778f429a50b3f1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 25 Dec 2019 13:14:48 -0500 Subject: [PATCH 12/14] haskell generic-builder: Fix `--with-ghc` flag for GHCJS as cross Otherwise it passes `--with-ghc=ghc`, and we do the wrong thing. --- pkgs/development/haskell-modules/generic-builder.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index d6966d69136..e27769d9c76 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -131,7 +131,7 @@ let ''; crossCabalFlags = [ - "--with-ghc=${ghc.targetPrefix}ghc" + "--with-ghc=${ghcCommand}" "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg" ] ++ optionals stdenv.hasCC [ "--with-gcc=${stdenv.cc.targetPrefix}cc" From d8dd3014120af31d4567de8247900a1088ec6e7b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 25 Dec 2019 14:34:40 -0500 Subject: [PATCH 13/14] haskell generic-builder: Hack so CPP without a CC works --- pkgs/development/haskell-modules/generic-builder.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index e27769d9c76..018979cf7ae 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -133,8 +133,11 @@ let crossCabalFlags = [ "--with-ghc=${ghcCommand}" "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg" + # Pass the "wrong" C compiler rather than none at all so packages that just + # use the C preproccessor still work, see + # https://github.com/haskell/cabal/issues/6466 for details. + "--with-gcc=${(if stdenv.hasCC then stdenv else buildPackages.stdenv).cc.targetPrefix}cc" ] ++ optionals stdenv.hasCC [ - "--with-gcc=${stdenv.cc.targetPrefix}cc" "--with-ld=${stdenv.cc.bintools.targetPrefix}ld" "--with-ar=${stdenv.cc.bintools.targetPrefix}ar" # use the one that comes with the cross compiler. From 6078f094c638faabc63cffe285dc91af4e04a741 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 30 Dec 2019 18:09:45 -0500 Subject: [PATCH 14/14] pkgs/stdenv/booter.nix: Add comment explaining hasCC trickery --- pkgs/stdenv/booter.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 8a574652204..51d617354e8 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -126,7 +126,11 @@ stageFuns: let if buildPackages.stdenv.cc.isClang or false then buildPackages.clang else buildPackages.gcc - else buildPackages.stdenv.cc; + else + # This will blow up if anything uses it, but that's OK. The `if + # buildPackages.stdenv.cc.isClang then ... else ...` would blow up + # everything, so we make sure to avoid that. + buildPackages.stdenv.cc; }; in dfold folder postStage (_: {}) withAllowCustomOverrides