From ff2d74b3294f5c5488ddd1aad2d05fbeb045a7af Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Wed, 4 Jan 2023 15:19:46 +0100 Subject: 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. --- pkgs/development/haskell-modules/generic-builder.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkgs/development/haskell-modules') diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index bf1f2c387ad9..a723e56c9e17 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -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 ++ -- cgit 1.4.1