From 918edbe485333376549aef70f923dd224bca6395 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 5 Mar 2018 21:33:49 +0800 Subject: [PATCH] haskell-generic-builder: Add `enableHsc2hsViaAsm` for Windows cross compilation --- pkgs/development/haskell-modules/generic-builder.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 3cdf2e2252b..45299e01369 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -32,6 +32,7 @@ in , enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version) , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin , enableStaticLibraries ? true +, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4" , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] , homepage ? "http://hackage.haskell.org/package/${pname}" , platforms ? with stdenv.lib.platforms; unix ++ windows # GHC can cross-compile @@ -114,9 +115,13 @@ let "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg" "--with-gcc=${stdenv.cc.targetPrefix}cc" "--with-ld=${stdenv.cc.bintools.targetPrefix}ld" - "--with-hsc2hs=${nativeGhc}/bin/hsc2hs" # not cross one + # use the one that comes with the cross compiler. + "--with-hsc2hs=${ghc.targetPrefix}hsc2hs" "--with-strip=${stdenv.cc.bintools.targetPrefix}strip" - ] ++ (if isHaLVM then [] else ["--hsc2hs-options=--cross-compile"]); + ] ++ optionals (!isHaLVM) [ + "--hsc2hs-option=--cross-compile" + (optionalString enableHsc2hsViaAsm "--hsc2hs-option=--via-asm") + ]; crossCabalFlagsString = stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);