haskell.compiler: unify logic determining whether NCG is available

This change only consolidates the logic for the source built GHCs which
have used the same logic (at least as long as you'd only use the
respective supported version ranges of the expressions as inputs).

Changed files
+23 -15
pkgs
+6 -3
pkgs/development/compilers/ghc/8.10.7.nix
···
{
lib,
stdenv,
···
libffi ? null,
libffi_3_3 ? null,
-
useLLVM ?
-
!(stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isPower || stdenv.targetPlatform.isSparc),
# 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.
···
stdenv.mkDerivation (
rec {
-
version = "8.10.7";
pname = "${targetPrefix}ghc${variantSuffix}";
src = fetchurl {
···
+
let
+
version = "8.10.7";
+
in
+
{
lib,
stdenv,
···
libffi ? null,
libffi_3_3 ? null,
+
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.
···
stdenv.mkDerivation (
rec {
+
inherit version;
pname = "${targetPrefix}ghc${variantSuffix}";
src = fetchurl {
+1 -5
pkgs/development/compilers/ghc/common-hadrian.nix
···
, # 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))
, # 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.
···
, # GHC can be built with system libffi or a bundled one.
libffi ? null
+
, 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.
+14
pkgs/development/compilers/ghc/common-have-ncg.nix
···
···
+
# 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)
+2 -7
pkgs/development/compilers/ghc/common-make-native-bignum.nix
···
# 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)
-
),
# 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.
···
# GHC can be built with system libffi or a bundled one.
libffi ? null,
+
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.