about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2023-01-04 15:19:46 +0100
committersternenseemann <sternenseemann@systemli.org>2023-01-04 15:50:28 +0100
commitff2d74b3294f5c5488ddd1aad2d05fbeb045a7af (patch)
tree9834ece17034bca4be2159391a410e138d54efe8 /pkgs/development/haskell-modules
parentb92fb601c2479f5c58c42fe35781347ba7f79d55 (diff)
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.
Diffstat (limited to 'pkgs/development/haskell-modules')
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix7
1 files changed, 5 insertions, 2 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index bf1f2c387ad9f..a723e56c9e17d 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 ++