From 9dbcebd15430ba55fc99647319ba34dcfa2fa4fc Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Tue, 6 Jun 2023 12:43:09 +0200 Subject: [PATCH] haskellPackages.mkDerivation: profiling depends on hostPlatform Whether profiling should or should not be enabled does indeed depend on GHC's target platform (or GHC in general, i.e. if it happens to be ghcjs, we need to disable it). The profiling objects it produces are excessively big if it is producing them for aarch64. However, in a Haskell packages' derivation, GHC's and the resulting derivation's platforms are offset GHC: BUILD--HOST---TARGET DRV: BUILD--HOST--(TARGET) since we need to execute GHC in the derivation (so its host is our build platform) and the machine code it produces need to be executable on the host platform we are targeting. Unless our derivation is building a compiler (or similar), the target platform of the derivation doesn't matter. stdenv exposes the platforms of the current derivation, not of GHC, so checking the host platform is prudent. Changing this doesn't have a lot of impact, since when cross-compiling Haskell packages (e.g. via pkgsCross), host and target platform will usually be the same. It does save unnecessary rebuilds in the buildHaskellPackages set though, since most of the packages in here don't care about the target platform, so they should be the same as their corresponding packages in the ordinary (natively compiled) haskellPackages set. In short, after this change pkgsCross.aarch64-multiplatform.hoogle == haskellPackages.hoogle holds whereas it would erroneously be compiled with different profiling settings before. --- pkgs/development/haskell-modules/generic-builder.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 53ba217ed19b..382f6715dc9f 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -34,7 +34,7 @@ in , doInstallIntermediates ? false , editedCabalFile ? null # aarch64 outputs otherwise exceed 2GB limit -, enableLibraryProfiling ? !(ghc.isGhcjs or stdenv.targetPlatform.isAarch64 or false) +, enableLibraryProfiling ? !(ghc.isGhcjs or stdenv.hostPlatform.isAarch64 or false) , enableExecutableProfiling ? false , profilingDetail ? "exported-functions" # TODO enable shared libs for cross-compiling