haskellPackages.mkDerivation: use CC_FOR_BUILD if !stdenv.hasCC

Previously, we would try to calculate the name of
buildPackages.stdenv.cc and then just hope that it is in PATH somehow.
This definitely doesn't work in all cases.

The new approach is to add buildPackages.stdenv.cc to depsBuildBuild
which also populates CC_FOR_BUILD which we can directly re-use.
This commit is contained in:
sternenseemann 2023-01-04 15:19:46 +01:00
parent b92fb601c2
commit ff2d74b329

View File

@ -171,7 +171,7 @@ let
# Pass the "wrong" C compiler rather than none at all so packages that just
# use the C preproccessor still work, see
# https://github.com/haskell/cabal/issues/6466 for details.
"--with-gcc=${(if stdenv.hasCC then stdenv else buildPackages.stdenv).cc.targetPrefix}cc"
"--with-gcc=${if stdenv.hasCC then "$CC" else "$CC_FOR_BUILD"}"
] ++ optionals stdenv.hasCC [
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
@ -246,7 +246,10 @@ let
allPkgconfigDepends = pkg-configDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++
optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
depsBuildBuild = [ nativeGhc ];
depsBuildBuild = [ nativeGhc ]
# CC_FOR_BUILD may be necessary if we have no C preprocessor for the host
# platform. See crossCabalFlags above for more details.
++ lib.optionals (!stdenv.hasCC) [ buildPackages.stdenv.cc ];
collectedToolDepends =
buildTools ++ libraryToolDepends ++ executableToolDepends ++
optionals doCheck testToolDepends ++