From d3bad452401c87015cf3a1ad754a6d14eb5e48fc Mon Sep 17 00:00:00 2001 From: Alex Tunstall Date: Sun, 23 Jul 2023 10:13:50 +0100 Subject: [PATCH] haskell.compiler.ghc*: assert cross is possible --- pkgs/development/compilers/ghc/8.10.7.nix | 3 +++ pkgs/development/compilers/ghc/common-hadrian.nix | 13 ++++++------- .../compilers/ghc/common-make-native-bignum.nix | 3 +++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index e223ef157df9..7597e40bfe9e 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -77,6 +77,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/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index f534ad3afd3e..a38706554dcc 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -239,6 +239,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; @@ -359,13 +365,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 !targetPlatform.isGhcjs -> targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - stdenv.mkDerivation ({ pname = "${targetPrefix}ghc${variantSuffix}"; inherit version; diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index e8cec98aaa36..dc8ddfd0d9c0 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -82,6 +82,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;