From 19fc2292942cfcb7c07dade739989a64545d812f Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 30 Nov 2021 23:00:11 +0100 Subject: [PATCH 1/2] haskell.compiler.*: use targetCC for hasGold check This is a bit shorter and more consistent with the rest of the file. --- pkgs/development/compilers/ghc/8.10.7.nix | 2 +- pkgs/development/compilers/ghc/8.8.4.nix | 2 +- pkgs/development/compilers/ghc/9.0.1.nix | 2 +- pkgs/development/compilers/ghc/head.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 5be64bebcd4d..49fe3417a442 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -134,7 +134,7 @@ let # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); + (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. variantSuffix = lib.concatStrings [ diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index ffa2c473eec6..9232eac0ce18 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -142,7 +142,7 @@ let # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); + (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. variantSuffix = lib.concatStrings [ diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix index d377328692cb..fda5de7c2531 100644 --- a/pkgs/development/compilers/ghc/9.0.1.nix +++ b/pkgs/development/compilers/ghc/9.0.1.nix @@ -129,7 +129,7 @@ let # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); + (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. variantSuffix = lib.concatStrings [ diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 537b735b4a21..35e52befe200 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -143,7 +143,7 @@ let # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); + (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. variantSuffix = lib.concatStrings [ From c23e14e33f207dd38b6cc50401493d640a4745db Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 30 Nov 2021 23:06:44 +0100 Subject: [PATCH 2/2] haskell.compiler.*: assert that host->target == build->target tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC, CXX, LD, AR, …, LLC, OPT and CLANG will be invoked by GHC's build system at build time in the build->target role. However, since we are passing absolute paths, they will get saved in GHC's settings file and later invoked at runtime, when they should be host->target. This means that the build->target and host->target tools need to be the same for our built GHC to work properly which is what we guard using these new asserts. Being able to drop these asserts would be a step towards cross-compiling GHC (as opposed to building a GHC cross-compiler which still works). --- pkgs/development/compilers/ghc/8.10.7.nix | 10 +++++++++- pkgs/development/compilers/ghc/8.8.4.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.0.1.nix | 10 +++++++++- pkgs/development/compilers/ghc/9.2.1.nix | 10 +++++++++- pkgs/development/compilers/ghc/head.nix | 10 +++++++++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 49fe3417a442..3f64b4fef53e 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, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages # build-tools , bootPkgs @@ -143,6 +143,14 @@ 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}"; diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index 9232eac0ce18..438e47f4a509 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages # build-tools , bootPkgs @@ -151,6 +151,14 @@ 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.8.4"; pname = "${targetPrefix}ghc${variantSuffix}"; diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix index fda5de7c2531..aea65aa479ef 100644 --- a/pkgs/development/compilers/ghc/9.0.1.nix +++ b/pkgs/development/compilers/ghc/9.0.1.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages # build-tools , bootPkgs @@ -138,6 +138,14 @@ 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.1"; pname = "${targetPrefix}ghc${variantSuffix}"; diff --git a/pkgs/development/compilers/ghc/9.2.1.nix b/pkgs/development/compilers/ghc/9.2.1.nix index 16543ce49bcd..ad5cd4bbb807 100644 --- a/pkgs/development/compilers/ghc/9.2.1.nix +++ b/pkgs/development/compilers/ghc/9.2.1.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages # build-tools , bootPkgs @@ -139,6 +139,14 @@ 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.1"; pname = "${targetPrefix}ghc${variantSuffix}"; diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 35e52befe200..79c72de63f26 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages # build-tools , bootPkgs @@ -152,6 +152,14 @@ 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 { inherit version; inherit (src) rev;