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.
This commit is contained in:
sternenseemann 2023-06-06 12:43:09 +02:00
parent 271e7a9d82
commit 9dbcebd154

View File

@ -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