diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix index c4a20e7af4bcf..6137777f27470 100644 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ b/pkgs/development/compilers/ghc/8.10.7-binary.nix @@ -204,7 +204,7 @@ let ghcBinDists.${distSetName}.${stdenv.hostPlatform.system} or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')"); - useLLVM = !stdenv.targetPlatform.isx86; + useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; }); libPath = lib.makeLibraryPath ( # Add arch-specific libraries. diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index c0d9e2b371f76..ed14b48743b01 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -1,3 +1,7 @@ +let + version = "8.10.7"; +in + { lib, stdenv, @@ -32,8 +36,7 @@ libffi ? null, libffi_3_3 ? null, - useLLVM ? - !(stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc), + useLLVM ? !(import ./common-have-ncg.nix { inherit lib stdenv version; }), # LLVM is conceptually a run-time-only dependency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a # build-time dependency too. @@ -271,7 +274,7 @@ in stdenv.mkDerivation ( rec { - version = "8.10.7"; + inherit version; pname = "${targetPrefix}ghc${variantSuffix}"; src = fetchurl { diff --git a/pkgs/development/compilers/ghc/9.2.4-binary.nix b/pkgs/development/compilers/ghc/9.2.4-binary.nix index c5a704e8ad869..e5e21a91b611a 100644 --- a/pkgs/development/compilers/ghc/9.2.4-binary.nix +++ b/pkgs/development/compilers/ghc/9.2.4-binary.nix @@ -193,12 +193,7 @@ let ) binDistUsed.archSpecificLibraries )).nixPackage; - # GHC has other native backends (like PowerPC), but here only the ones - # we ship bindists for matter. - useLLVM = - !( - stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin) - ); + useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; }); libPath = lib.makeLibraryPath ( # Add arch-specific libraries. diff --git a/pkgs/development/compilers/ghc/9.6.3-binary.nix b/pkgs/development/compilers/ghc/9.6.3-binary.nix index ef4828814854a..e392fdd02f5bf 100644 --- a/pkgs/development/compilers/ghc/9.6.3-binary.nix +++ b/pkgs/development/compilers/ghc/9.6.3-binary.nix @@ -192,12 +192,7 @@ let ) binDistUsed.archSpecificLibraries )).nixPackage; - # GHC has other native backends (like PowerPC), but here only the ones - # we ship bindists for matter. - useLLVM = - !( - stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin) - ); + useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; }); libPath = lib.makeLibraryPath ( # Add arch-specific libraries. diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 3a6ea450f37ed..7974cba0824c9 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -39,11 +39,7 @@ , # GHC can be built with system libffi or a bundled one. libffi ? null -, useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || stdenv.targetPlatform.isAarch64 - || stdenv.targetPlatform.isGhcjs - || (lib.versionAtLeast version "9.12" && stdenv.targetPlatform.isRiscV64)) +, useLLVM ? !(import ./common-have-ncg.nix { inherit lib stdenv version; }) , # LLVM is conceptually a run-time-only dependency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a # build-time dependency too. diff --git a/pkgs/development/compilers/ghc/common-have-ncg.nix b/pkgs/development/compilers/ghc/common-have-ncg.nix new file mode 100644 index 0000000000000..1b92a0700ac2e --- /dev/null +++ b/pkgs/development/compilers/ghc/common-have-ncg.nix @@ -0,0 +1,14 @@ +# Determines whether the Native Code Generation (NCG) backend of the given +# GHC `version` is supported for compiling to `stdenv.targetPlatform`. +{ + version, + stdenv, + lib, +}: + +stdenv.targetPlatform.isx86 +|| stdenv.targetPlatform.isPower +|| (lib.versionOlder version "9.4" && stdenv.targetPlatform.isSparc) +|| (lib.versionAtLeast version "9.2" && stdenv.targetPlatform.isAarch64) +|| (lib.versionAtLeast version "9.6" && stdenv.targetPlatform.isGhcjs) +|| (lib.versionAtLeast version "9.12" && stdenv.targetPlatform.isRiscV64) diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index 412e8d7d4671c..b204a1c703638 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -34,13 +34,8 @@ # GHC can be built with system libffi or a bundled one. libffi ? null, - useLLVM ? - !( - stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || (lib.versionOlder version "9.4" && stdenv.targetPlatform.isSparc) - || (lib.versionAtLeast version "9.2" && stdenv.targetPlatform.isAarch64) - ), + useLLVM ? !(import ./common-have-ncg.nix { inherit lib stdenv version; }), + # LLVM is conceptually a run-time-only dependency, but for # non-x86, we need LLVM to bootstrap later stages, so it becomes a # build-time dependency too.