@@ -32,6 +32,7 @@ in
3232, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
3333, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
3434, enableStaticLibraries ? true
35+, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
3536, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
3637, homepage ? "http://hackage.haskell.org/package/${pname}"
3738, platforms ? with stdenv.lib.platforms; unix ++ windows # GHC can cross-compile
@@ -114,9 +115,13 @@ let
114115 "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
115116 "--with-gcc=${stdenv.cc.targetPrefix}cc"
116117 "--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
117− "--with-hsc2hs=${nativeGhc}/bin/hsc2hs" # not cross one
118+ # use the one that comes with the cross compiler.
119+ "--with-hsc2hs=${ghc.targetPrefix}hsc2hs"
118120 "--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
119− ] ++ (if isHaLVM then [] else ["--hsc2hs-options=--cross-compile"]);
121+ ] ++ optionals (!isHaLVM) [
122+ "--hsc2hs-option=--cross-compile"
123+ (optionalString enableHsc2hsViaAsm "--hsc2hs-option=--via-asm")
124+ ];
120125
121126 crossCabalFlagsString =
122127 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);