From c3ab42d1669907548d0bd0c306e85adc55fd4650 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Fri, 21 Jul 2023 19:43:22 +0100 Subject: [PATCH 01/12] haskell.compiler.ghc8107: support {LD,AR}_STAGE0 --- pkgs/development/compilers/ghc/8.10.7.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 4a770d993a678..cc819ff8dcbfd 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -2,7 +2,7 @@ # build-tools , bootPkgs -, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx +, autoreconfHook, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx , xattr, autoSignDarwinBinariesHook , bash @@ -223,6 +223,12 @@ stdenv.mkDerivation (rec { stripLen = 3; extraPrefix = "libraries/Cabal/Cabal/"; }) + + # We need to be able to set AR_STAGE0 and LD_STAGE0 when cross-compiling + (fetchpatch { + url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch"; + hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s="; + }) ] ++ lib.optionals stdenv.isDarwin [ # Make Block.h compile with c++ compilers. Remove with the next release (fetchpatch { @@ -334,7 +340,7 @@ stdenv.mkDerivation (rec { dontAddExtraLibs = true; nativeBuildInputs = [ - perl autoconf automake m4 python3 + perl autoreconfHook autoconf automake m4 python3 ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook From ebf54626c9b419e5b13c0faf5e03e972a43b2d26 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 09:30:35 +0100 Subject: [PATCH 02/12] haskell.compiler.ghc*: set stage 0 tools --- pkgs/development/compilers/ghc/8.10.7.nix | 9 ++++++++- pkgs/development/compilers/ghc/9.0.2.nix | 9 ++++++++- pkgs/development/compilers/ghc/9.2.5.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.2.6.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.2.7.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.2.8.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.4.5.nix | 9 ++++++++- pkgs/development/compilers/ghc/9.4.6.nix | 9 ++++++++- pkgs/development/compilers/ghc/9.4.7.nix | 9 ++++++++- pkgs/development/compilers/ghc/9.4.8.nix | 9 ++++++++- pkgs/development/compilers/ghc/common-hadrian.nix | 8 ++++++++ 11 files changed, 92 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index cc819ff8dcbfd..5ca04fdc16418 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -247,6 +248,9 @@ stdenv.mkDerivation (rec { postPatch = "patchShebangs ."; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -275,6 +279,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 175d1fe2450b7..41ffdb9adbf0c 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -224,6 +225,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -252,6 +256,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 6c86e05ebbd4c..e367ce0a2004f 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -223,6 +224,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +255,10 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 6ff58f087f8a9..85d2b39a984cd 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -223,6 +224,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +255,10 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index f605bfda1981f..e1a32ed45a3a4 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -223,6 +224,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +255,10 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 72cfdd242f424..f0ac8f669f9d3 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -129,6 +129,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -223,6 +224,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +255,10 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 298af6596e713..9d9470a408e89 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -131,6 +131,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -220,6 +221,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -248,6 +252,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 310787e477b24..f356c135e2f2c 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -131,6 +131,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -216,6 +217,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -244,6 +248,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index e87f8fc3a9073..d5d212d6e6014 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -131,6 +131,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -212,6 +213,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -240,6 +244,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 5ac2b60b1cd75..94804c27cb121 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -131,6 +131,7 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -212,6 +213,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -240,6 +244,9 @@ stdenv.mkDerivation (rec { # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 465db3a252964..5904c017a4904 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -12,6 +12,7 @@ , stdenv , pkgsBuildTarget , pkgsHostTarget +, buildPackages , targetPackages # build-tools @@ -215,6 +216,7 @@ let else pkgsBuildTarget.targetPackages.stdenv.cc) ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped @@ -286,12 +288,18 @@ stdenv.mkDerivation ({ # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do export "''${env#TARGET_}=''${!env}" done + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" # GHC is a bit confused on its cross terminology, as these would normally be # the *host* tools. export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" From 80b2ffdad2bd005cf4eec618971d4b275bb1db5b Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 09:43:41 +0100 Subject: [PATCH 03/12] haskell.compiler.ghc*: fix libffi cross dependency --- pkgs/development/compilers/ghc/8.10.7.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.0.2.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.2.5.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.2.6.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.2.7.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.2.8.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.4.5.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.4.6.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.4.7.nix | 8 ++++++-- pkgs/development/compilers/ghc/9.4.8.nix | 8 ++++++-- pkgs/development/compilers/ghc/common-hadrian.nix | 8 ++++++-- 11 files changed, 66 insertions(+), 22 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 5ca04fdc16418..7674d1bd40e64 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableIntegerSimple "-integer-simple") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -322,8 +326,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 41ffdb9adbf0c..71f496cb83daf 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -298,8 +302,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index e367ce0a2004f..69d248eaa512c 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -299,8 +303,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 85d2b39a984cd..397402c9557cf 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -299,8 +303,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index e1a32ed45a3a4..1dfe2b41d1297 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -299,8 +303,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index f0ac8f669f9d3..3ba5a8b19c761 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -162,6 +162,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -299,8 +303,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 9d9470a408e89..7a8fa04e0714c 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -164,6 +164,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -305,8 +309,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index f356c135e2f2c..062b5b990e704 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -164,6 +164,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -301,8 +305,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index d5d212d6e6014..49dd07e73152e 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -164,6 +164,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -297,8 +301,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 94804c27cb121..fab7d53c4284f 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -164,6 +164,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -297,8 +301,8 @@ stdenv.mkDerivation (rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 5904c017a4904..035e90a4917a5 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -249,6 +249,10 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -390,8 +394,8 @@ stdenv.mkDerivation ({ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ lib.optionals (libffi != null && !targetPlatform.isGhcjs) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" From bc44d9a5a18af60d74d4a0df6820ab017cb85853 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 09:50:55 +0100 Subject: [PATCH 04/12] haskell.compiler.ghc*: fix ncurses splicing --- pkgs/development/compilers/ghc/8.10.7.nix | 3 ++- pkgs/development/compilers/ghc/9.0.2.nix | 3 ++- pkgs/development/compilers/ghc/9.2.5.nix | 3 ++- pkgs/development/compilers/ghc/9.2.6.nix | 3 ++- pkgs/development/compilers/ghc/9.2.7.nix | 3 ++- pkgs/development/compilers/ghc/9.2.8.nix | 3 ++- pkgs/development/compilers/ghc/9.4.5.nix | 3 ++- pkgs/development/compilers/ghc/9.4.6.nix | 3 ++- pkgs/development/compilers/ghc/9.4.7.nix | 3 ++- pkgs/development/compilers/ghc/9.4.8.nix | 3 ++- pkgs/development/compilers/ghc/common-hadrian.nix | 3 ++- 11 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 7674d1bd40e64..3de2f40e2b837 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -323,7 +323,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 71f496cb83daf..b0e77a9375daa 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -299,7 +299,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 69d248eaa512c..90ed58b08b371 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -300,7 +300,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 397402c9557cf..c7c603a6b6a9c 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -300,7 +300,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index 1dfe2b41d1297..64fd2995c26ee 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -300,7 +300,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 3ba5a8b19c761..9a8b5e049e566 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -300,7 +300,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 7a8fa04e0714c..38d85d0e6199c 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -306,7 +306,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 062b5b990e704..0685e5e5e60e1 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -302,7 +302,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index 49dd07e73152e..8fe3269616fe8 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -298,7 +298,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index fab7d53c4284f..745cd44a33cba 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -298,7 +298,8 @@ stdenv.mkDerivation (rec { # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 035e90a4917a5..c8072dc63eb3d 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -391,7 +391,8 @@ stdenv.mkDerivation ({ # `--with` flags for libraries needed for RTS linker configureFlags = [ "--datadir=$doc/share/doc/ghc" - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null && !targetPlatform.isGhcjs) [ "--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" From f0653bb85e4b59a1063e85b3d883f06aabfff8e0 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 09:56:56 +0100 Subject: [PATCH 05/12] haskell.compiler.ghc*: don't configure --host --- pkgs/development/compilers/ghc/8.10.7.nix | 7 +++++-- pkgs/development/compilers/ghc/9.0.2.nix | 7 +++++-- pkgs/development/compilers/ghc/9.2.5.nix | 7 +++++-- pkgs/development/compilers/ghc/9.2.6.nix | 7 +++++-- pkgs/development/compilers/ghc/9.2.7.nix | 7 +++++-- pkgs/development/compilers/ghc/9.2.8.nix | 7 +++++-- pkgs/development/compilers/ghc/9.4.5.nix | 7 +++++-- pkgs/development/compilers/ghc/9.4.6.nix | 7 +++++-- pkgs/development/compilers/ghc/9.4.7.nix | 7 +++++-- pkgs/development/compilers/ghc/9.4.8.nix | 7 +++++-- 10 files changed, 50 insertions(+), 20 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 3de2f40e2b837..139168d85509c 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -316,9 +316,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index b0e77a9375daa..43a9d5d5d4418 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -292,9 +292,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 90ed58b08b371..876bdddb2d3e9 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -293,9 +293,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index c7c603a6b6a9c..b07d38f1256e8 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -293,9 +293,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index 64fd2995c26ee..ddce0419009f8 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -293,9 +293,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 9a8b5e049e566..c7a4f98abb95d 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -293,9 +293,12 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 38d85d0e6199c..bef601f8babf5 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -299,9 +299,12 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 0685e5e5e60e1..1ea39ed1dd163 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -295,9 +295,12 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index 8fe3269616fe8..7d0c7af41507a 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -291,9 +291,12 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 745cd44a33cba..643078618a91d 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -291,9 +291,12 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target"; # `--with` flags for libraries needed for RTS linker configureFlags = [ From b0379b4e1638352196c645f2605b813bc5afc011 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:01:19 +0100 Subject: [PATCH 06/12] haskell.compiler.ghc*: use target CC in settings --- pkgs/development/compilers/ghc/8.10.7.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.0.2.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.2.5.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.2.6.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.2.7.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.2.8.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.4.5.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.4.6.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.4.7.nix | 16 +++++++++------- pkgs/development/compilers/ghc/9.4.8.nix | 16 +++++++++------- .../compilers/ghc/common-hadrian.nix | 17 +++++++++++++---- 11 files changed, 103 insertions(+), 74 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 139168d85509c..2f00aac5f656a 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "8.10.7"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -393,6 +387,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 43a9d5d5d4418..445d0257e345d 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.0.2"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -373,6 +367,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 876bdddb2d3e9..e57ce8fc81318 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.2.5"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -370,6 +364,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index b07d38f1256e8..73d4a373d6230 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.2.6"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -370,6 +364,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index ddce0419009f8..3d9e9cdcbd58a 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.2.7"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -370,6 +364,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index c7a4f98abb95d..b28f6142aa7ec 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -131,6 +131,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -168,13 +169,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.2.8"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -370,6 +364,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index bef601f8babf5..883a4cb416681 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -133,6 +133,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -170,13 +171,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.4.5"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -376,6 +370,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 1ea39ed1dd163..bc0b7407b88e8 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -133,6 +133,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -170,13 +171,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.4.6"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -372,6 +366,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index 7d0c7af41507a..63aab7a6a7ffb 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -133,6 +133,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -170,13 +171,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.4.7"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -368,6 +362,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 643078618a91d..426b25b0bfb7c 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -133,6 +133,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -170,13 +171,6 @@ let in -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation (rec { version = "9.4.8"; pname = "${targetPrefix}ghc${variantSuffix}"; @@ -368,6 +362,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index c8072dc63eb3d..79bfa3fed6b91 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -218,6 +218,7 @@ let buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -253,6 +254,9 @@ let then targetPackages.libffi else pkgsHostTarget.libffi; + # Our Cabal compiler name + haskellCompilerName = "ghc-${version}"; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -512,19 +516,24 @@ stdenv.mkDerivation ({ # leave bindist directory popd + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${haskellCompilerName}/lib/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -Dm 644 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; passthru = { - inherit bootPkgs targetPrefix; + inherit bootPkgs targetPrefix haskellCompilerName; inherit llvmPackages; inherit enableShared; - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - # Expose hadrian used for bootstrapping, for debugging purposes inherit hadrian; From b41be4b1dbd3f3e623d9158ee81c3688a3281899 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:10:04 +0100 Subject: [PATCH 07/12] haskell.compiler.ghc*: don't cross-compile haddock --- pkgs/development/compilers/ghc/8.10.7.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.0.2.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.2.5.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.2.6.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.2.7.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.2.8.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.4.5.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.4.6.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.4.7.nix | 11 ++++++----- pkgs/development/compilers/ghc/9.4.8.nix | 11 ++++++----- pkgs/development/compilers/ghc/common-hadrian.nix | 7 ++++--- 11 files changed, 64 insertions(+), 53 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 2f00aac5f656a..c74ad45e69015 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -44,14 +44,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -62,7 +63,7 @@ assert !enableIntegerSimple -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 445d0257e345d..1b48248df6192 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -46,14 +46,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -64,7 +65,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index e57ce8fc81318..08140b362079a 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -46,14 +46,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -64,7 +65,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 73d4a373d6230..eb8c7cf064c4e 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -46,14 +46,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -64,7 +65,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index 3d9e9cdcbd58a..b375640a1500e 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -46,14 +46,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -64,7 +65,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index b28f6142aa7ec..788620c689079 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -46,14 +46,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -64,7 +65,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 883a4cb416681..5aa87af4ab459 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -48,14 +48,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -66,7 +67,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index bc0b7407b88e8..560db6e4b66c7 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -48,14 +48,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -66,7 +67,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index 63aab7a6a7ffb..a36a319593328 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -48,14 +48,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -66,7 +67,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 426b25b0bfb7c..288ba8600ba54 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -48,14 +48,15 @@ , # Whether to build sphinx documentation. enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ @@ -66,7 +67,7 @@ assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 79bfa3fed6b91..6f4cd7351b81e 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -165,9 +165,10 @@ , # Whether to build sphinx documentation. # TODO(@sternenseemann): Hadrian ignores the --docs flag if finalStage = Stage1 enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , # Whether to disable the large address space allocator From 8f422a53bd5d320acae505dc8c609226e3b8bd39 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:12:19 +0100 Subject: [PATCH 08/12] haskell.compiler.ghc*: add enableUnregisterised --- pkgs/development/compilers/ghc/8.10.7.nix | 8 ++++++++ pkgs/development/compilers/ghc/9.0.2.nix | 8 ++++++++ pkgs/development/compilers/ghc/9.2.5.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.2.6.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.2.7.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.2.8.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.4.5.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.4.6.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.4.7.nix | 10 ++++++++++ pkgs/development/compilers/ghc/9.4.8.nix | 10 ++++++++++ pkgs/development/compilers/ghc/common-hadrian.nix | 8 ++++++++ 11 files changed, 104 insertions(+) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index c74ad45e69015..b2816e0865cd2 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -57,6 +57,12 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableIntegerSimple -> gmp != null; @@ -341,6 +347,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 1b48248df6192..53b22a50e5ebe 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -59,6 +59,12 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableNativeBignum -> gmp != null; @@ -317,6 +323,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 08140b362079a..079b104b26b28 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -59,6 +59,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -318,6 +326,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index eb8c7cf064c4e..520a0e6856be1 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -59,6 +59,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -318,6 +326,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index b375640a1500e..824013820666b 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -59,6 +59,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -318,6 +326,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 788620c689079..5c5b36baa3f3a 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -59,6 +59,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -318,6 +326,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 5aa87af4ab459..0cd649f38ad2a 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -61,6 +61,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -324,6 +332,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 560db6e4b66c7..e9fd9839dca66 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -61,6 +61,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -320,6 +328,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index a36a319593328..8ff90e7b2fd24 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -61,6 +61,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -316,6 +324,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 288ba8600ba54..7414adc42311c 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -61,6 +61,14 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; @@ -316,6 +324,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 6f4cd7351b81e..b8924f25aad89 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -174,6 +174,12 @@ , # Whether to disable the large address space allocator # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ disableLargeAddressSpace ? stdenv.targetPlatform.isiOS + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableNativeBignum -> gmp != null; @@ -426,6 +432,8 @@ stdenv.mkDerivation ({ # https://gitlab.haskell.org/ghc/ghc/-/issues/23188 # https://github.com/haskell/cabal/issues/8882 "fp_cv_prog_ar_supports_dash_l=no" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. From 1801e2756b0092c2b7121e0c163b18fa3465a122 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:13:50 +0100 Subject: [PATCH 09/12] haskell.compiler.ghc*: assert cross is possible --- pkgs/development/compilers/ghc/8.10.7.nix | 3 +++ pkgs/development/compilers/ghc/9.0.2.nix | 3 +++ pkgs/development/compilers/ghc/9.2.5.nix | 3 +++ pkgs/development/compilers/ghc/9.2.6.nix | 3 +++ pkgs/development/compilers/ghc/9.2.7.nix | 3 +++ pkgs/development/compilers/ghc/9.2.8.nix | 3 +++ pkgs/development/compilers/ghc/9.4.5.nix | 3 +++ pkgs/development/compilers/ghc/9.4.6.nix | 3 +++ pkgs/development/compilers/ghc/9.4.7.nix | 3 +++ pkgs/development/compilers/ghc/9.4.8.nix | 3 +++ pkgs/development/compilers/ghc/common-hadrian.nix | 6 ++++++ 11 files changed, 36 insertions(+) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index b2816e0865cd2..9e8349013785b 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -71,6 +71,9 @@ assert !enableIntegerSimple -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 53b22a50e5ebe..419c42b051dfc 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -73,6 +73,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 079b104b26b28..6aa224875d10b 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -75,6 +75,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 520a0e6856be1..801322c27e8f0 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -75,6 +75,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index 824013820666b..10e78d1eff4cb 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -75,6 +75,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 5c5b36baa3f3a..1c6ea908e36eb 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -75,6 +75,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 0cd649f38ad2a..c1756ee561162 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -77,6 +77,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index e9fd9839dca66..685cb185e700f 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -77,6 +77,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index 8ff90e7b2fd24..d00d890bc1c52 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -77,6 +77,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 7414adc42311c..6dfc3e20e280c 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -77,6 +77,9 @@ assert !enableNativeBignum -> gmp != null; # see note [HADDOCK_DOCS]. assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index b8924f25aad89..ac3963b7b4290 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -184,6 +184,12 @@ assert !enableNativeBignum -> gmp != null; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + +# It is currently impossible to cross-compile GHC with Hadrian. +assert stdenv.buildPlatform == stdenv.hostPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; From 640b562659af9ade041705be250e6a766165b55a Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:16:26 +0100 Subject: [PATCH 10/12] haskell.compiler.ghc*: allow all platforms Propagating the supported platforms of the boot compiler doesn't make much sense when unregistered cross-compilation is possible. --- pkgs/development/compilers/ghc/8.10.7.nix | 3 ++- pkgs/development/compilers/ghc/9.0.2.nix | 3 ++- pkgs/development/compilers/ghc/9.2.5.nix | 3 ++- pkgs/development/compilers/ghc/9.2.6.nix | 3 ++- pkgs/development/compilers/ghc/9.2.7.nix | 3 ++- pkgs/development/compilers/ghc/9.2.8.nix | 3 ++- pkgs/development/compilers/ghc/9.4.5.nix | 3 ++- pkgs/development/compilers/ghc/9.4.6.nix | 3 ++- pkgs/development/compilers/ghc/9.4.7.nix | 3 ++- pkgs/development/compilers/ghc/9.4.8.nix | 3 ++- pkgs/development/compilers/ghc/common-hadrian.nix | 3 ++- 11 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 9e8349013785b..c2dcf2bad1966 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -432,7 +432,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 419c42b051dfc..4080798154a79 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -412,7 +412,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 6aa224875d10b..36ede2a27aa7c 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -411,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 801322c27e8f0..af3a231baf4ab 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -411,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index 10e78d1eff4cb..a9f8cc4bf680d 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -411,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 1c6ea908e36eb..c8ca7f5c1d603 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -411,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index c1756ee561162..3060a91a85c91 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -417,7 +417,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 685cb185e700f..82dcbbebf2141 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -413,7 +413,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index d00d890bc1c52..0ea5eca3ce9c6 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -409,7 +409,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 6dfc3e20e280c..56f41620198e7 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -409,7 +409,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index ac3963b7b4290..c5eeb10017615 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -564,7 +564,8 @@ stdenv.mkDerivation ({ guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; # https://github.com/NixOS/nixpkgs/issues/208959 broken = (lib.versionAtLeast version "9.6" && lib.versionOlder version "9.8") From d64620d29995f377340a280302029db33dde7b08 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:18:58 +0100 Subject: [PATCH 11/12] haskell.compiler.ghc*: use GHC from pkgsBuildBuild --- pkgs/top-level/haskell-packages.nix | 145 ++++++++++++++-------------- 1 file changed, 73 insertions(+), 72 deletions(-) diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index ddfd8146b53d0..5568cf80bed2d 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -1,4 +1,4 @@ -{ buildPackages, pkgsBuildTarget, pkgs, newScope, stdenv }: +{ buildPackages, pkgsBuildBuild, pkgsBuildTarget, pkgs, newScope, stdenv }: let # These are attributes in compiler that support integer-simple. @@ -52,7 +52,8 @@ in { package-list = callPackage ../development/haskell-modules/package-list.nix {}; - compiler = { + # Always get boot compilers from `pkgsBuildBuild` + compiler = let bb = pkgsBuildBuild.haskell; in { ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix { # Should be llvmPackages_6 which has been removed from nixpkgs llvmPackages = null; @@ -73,11 +74,11 @@ in { ghc8107 = callPackage ../development/compilers/ghc/8.10.7.nix { bootPkgs = # the oldest ghc with aarch64-darwin support is 8.10.5 - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then # to my (@a-m-joseph) knowledge there are no newer official binaries for this platform - packages.ghc865Binary + bb.packages.ghc865Binary else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -90,10 +91,10 @@ in { ghc902 = callPackage ../development/compilers/ghc/9.0.2.nix { bootPkgs = # the oldest ghc with aarch64-darwin support is 8.10.5 - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; inherit (buildPackages.darwin) autoSignDarwinBinariesHook xattr; buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_12; @@ -102,10 +103,10 @@ in { ghc90 = compiler.ghc902; ghc925 = callPackage ../development/compilers/ghc/9.2.5.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -116,10 +117,10 @@ in { }; ghc926 = callPackage ../development/compilers/ghc/9.2.6.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -130,10 +131,10 @@ in { }; ghc927 = callPackage ../development/compilers/ghc/9.2.7.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -144,10 +145,10 @@ in { }; ghc928 = callPackage ../development/compilers/ghc/9.2.8.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -164,14 +165,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -188,14 +189,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -212,14 +213,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -236,14 +237,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -257,12 +258,12 @@ in { ghc963 = callPackage ../development/compilers/ghc/9.6.3.nix { bootPkgs = # For GHC 9.2 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc928 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc928 + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc928 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc928 else - packages.ghc924Binary; + bb.packages.ghc924Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -275,12 +276,12 @@ in { ghc964 = callPackage ../development/compilers/ghc/9.6.4.nix { bootPkgs = # For GHC 9.2 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc928 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc928 + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc928 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc928 else - packages.ghc924Binary; + bb.packages.ghc924Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -294,19 +295,19 @@ in { ghc981 = callPackage ../development/compilers/ghc/9.8.1.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -319,19 +320,19 @@ in { ghc982 = callPackage ../development/compilers/ghc/9.8.2.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -345,19 +346,19 @@ in { ghcHEAD = callPackage ../development/compilers/ghc/head.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -370,7 +371,7 @@ in { ghcjs = compiler.ghcjs810; ghcjs810 = callPackage ../development/compilers/ghcjs/8.10 { - bootPkgs = packages.ghc810; + bootPkgs = bb.packages.ghc810; ghcjsSrcJson = ../development/compilers/ghcjs/8.10/git.json; stage0 = ../development/compilers/ghcjs/8.10/stage0.nix; }; From 4e0921f5217f18d92373b4c9d5a8b9ee0ad62085 Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Fri, 29 Mar 2024 10:05:19 +0000 Subject: [PATCH 12/12] tests.cross.sanity: Add GHC to catch regressions This is to ensure that Haskell users on platforms that lack official bindists still have a convenient means of getting GHC running natively. In my admittedly somewhat limited testing on RISC-V, GHC 8.10.7 is able to bootstrap native builds for 9.2.8 and 9.4.5. GHC 9.2.8 and 9.4.5 are unable to bootstrap themselves and 9.6.2 when cross-compiled. If you're looking at this commit to see whether you can safely upgrade the compiler used here to remove 8.10, please try cross-compiling 9.0 or later and then booting a native GHC with it. --- pkgs/test/cross/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/test/cross/default.nix b/pkgs/test/cross/default.nix index bd233db4cd50f..7f5a777794d5c 100644 --- a/pkgs/test/cross/default.nix +++ b/pkgs/test/cross/default.nix @@ -146,6 +146,8 @@ let pkgs.pkgsCross.mips64el-linux-gnuabi64.stdenv pkgs.pkgsCross.mips64el-linux-gnuabin32.stdenv pkgs.pkgsCross.mingwW64.stdenv + # Unlike later versions, cross-compiled 8.10.7 can reliably bootstrap a native build + pkgs.pkgsCross.riscv64.haskell.compiler.integer-simple.ghc8107 ] ++ lib.optionals (with pkgs.stdenv.buildPlatform; isx86_64 && isLinux) [ # Musl-to-glibc cross on the same architecture tends to turn up