From a4d5dbd45dfe35ca93b32daedba1c25167701cb0 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 11 Mar 2018 17:13:25 +0800 Subject: [PATCH] haskell generic builder: Disable static libs on Windows because no -staticlib The reason why this does not work is not that we can't built static objects, we can, but we can't use `-staticlib` on GHC on windows. `-staticlib` rolls all dependencies into a combined archive. While this would work on windows if we used gnu ar and MRI script, GHC can't rely on GNU ar, and as such has a quick archive concatenation module for GNU and BSD archives only. --- pkgs/development/haskell-modules/generic-builder.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index b0cf228f8c7..66c8c1fd375 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -31,7 +31,7 @@ in , enableSharedExecutables ? false , enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version) , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin -, enableStaticLibraries ? true +, enableStaticLibraries ? !hostPlatform.isWindows , enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4" , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] , homepage ? "http://hackage.haskell.org/package/${pname}" @@ -68,6 +68,10 @@ in assert editedCabalFile != null -> revision != null; +# --enable-static does not work on windows. This is a bug in GHC. +# --enable-static will pass -staticlib to ghc, which only works for mach-o and elf. +assert hostPlatform.isWindows -> enableStaticLibraries == false; + let inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast