on iko/ghcjs-patch-master help sign in
Fixes for windows cross compilation (#1103)
commitae7be4559f30f924d0f0bedd7ae130113e3a995f authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateMon 3 May 2021, 19:14 (5 years ago) parent6cfc1d4
6 files changed+57−14
builder/comp-builder.nix+1−1 builder/make-config-files.nix+2−1 overlays/hackage-quirks.nix−11 overlays/mingw_w64.nix+1−1 overlays/patches/file-embed.patch+52 overlays/windows.nix+1
builder/comp-builder.nix+1−1
@@ -467,7 +467,7 @@ let
467467 # to symlink over dlls as needed.
468468 + ''
469469 echo "Symlink library dependencies..."
470− for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
470+ for libdir in $(${stdenv.hostPlatform.config}-ghc-pkg field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
471471 if [ -d "$libdir" ]; then
472472 find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
473473 fi
builder/make-config-files.nix+2−1
@@ -81,7 +81,8 @@ let
8181 ${target-pkg} init $out/${packageCfgDir}
8282
8383 ${lib.concatStringsSep "\n" (lib.mapAttrsToList flagsAndConfig {
84− "extra-lib-dirs" = map (p: "${lib.getLib p}/lib") component.libs;
84+ "extra-lib-dirs" = map (p: "${lib.getLib p}/lib") component.libs
85+ ++ lib.optionals (stdenv.hostPlatform.isWindows) (map (p: "${lib.getBin p}/bin") component.libs);
8586 "extra-include-dirs" = map (p: "${lib.getDev p}/include") component.libs;
8687 "extra-framework-dirs" = map (p: "${p}/Library/Frameworks") component.frameworks;
8788 })}
overlays/hackage-quirks.nix−11
@@ -58,17 +58,6 @@ in { haskell-nix = prev.haskell-nix // {
5858 { "https://github.com/jgm/pandoc-citeproc"."0.17"
5959 = "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; }
6060 ."${location}"."${tag}";
61− modules = [
62− # Windows characters confuse cross compilation
63− # See https://github.com/snoyberg/file-embed/pull/33
64− (lib.optionalAttrs (version == "2.9.2.1") {
65− packages.file-embed.src = final.evalPackages.fetchgit {
66− url = "https://github.com/hamishmack/file-embed.git";
67− rev = "12b33b8b710517308954c1facff3dc679c2dc5e3";
68− sha256 = "0jcpja4s4cylmg9rddyakb1p1fb4l41ffwmy0njpb1dxc5z3v618";
69− };
70− })
71− ];
7261 };
7362
7463 # See https://github.com/input-output-hk/haskell.nix/issues/948
overlays/mingw_w64.nix+1−1
@@ -101,7 +101,7 @@ let
101101 # we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
102102 # to copy over dlls as needed.
103103 echo "Copying library dependencies..."
104− for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
104+ for libdir in $(${hostPlatform.config}-ghc-pkg field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
105105 if [ -d "$libdir" ]; then
106106 find "$libdir" -iname '*.dll' -exec cp {} . \;
107107 fi
overlays/patches/file-embed.patchnew file+52
@@ -0,0 +1,52 @@
1+diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs
2+index ca796c0..21c5835 100644
3+--- a/Data/FileEmbed.hs
4++++ b/Data/FileEmbed.hs
5+@@ -51,7 +51,6 @@ import Language.Haskell.TH.Syntax
6+ , runIO
7+ , qLocation, loc_filename
8+ #if MIN_VERSION_template_haskell(2,7,0)
9+- , Quasi(qAddDependentFile)
10+ #endif
11+ )
12+ #if MIN_VERSION_template_haskell(2,16,0)
13+@@ -83,7 +82,6 @@ import Data.Ord (comparing)
14+ embedFile :: FilePath -> Q Exp
15+ embedFile fp =
16+ #if MIN_VERSION_template_haskell(2,7,0)
17+- qAddDependentFile fp >>
18+ #endif
19+ (runIO $ B.readFile fp) >>= bsToExp
20+
21+@@ -98,7 +96,6 @@ embedOneFileOf :: [FilePath] -> Q Exp
22+ embedOneFileOf ps =
23+ (runIO $ readExistingFile ps) >>= \ ( path, content ) -> do
24+ #if MIN_VERSION_template_haskell(2,7,0)
25+- qAddDependentFile path
26+ #endif
27+ bsToExp content
28+ where
29+@@ -142,7 +139,6 @@ getDir = fileList
30+ pairToExp :: FilePath -> (FilePath, B.ByteString) -> Q Exp
31+ pairToExp _root (path, bs) = do
32+ #if MIN_VERSION_template_haskell(2,7,0)
33+- qAddDependentFile $ _root ++ '/' : path
34+ #endif
35+ exp' <- bsToExp bs
36+ return $! TupE
37+@@ -187,7 +183,6 @@ stringToBs = B8.pack
38+ embedStringFile :: FilePath -> Q Exp
39+ embedStringFile fp =
40+ #if MIN_VERSION_template_haskell(2,7,0)
41+- qAddDependentFile fp >>
42+ #endif
43+ (runIO $ P.readFile fp) >>= strToExp
44+
45+@@ -199,7 +194,6 @@ embedOneStringFileOf :: [FilePath] -> Q Exp
46+ embedOneStringFileOf ps =
47+ (runIO $ readExistingFile ps) >>= \ ( path, content ) -> do
48+ #if MIN_VERSION_template_haskell(2,7,0)
49+- qAddDependentFile path
50+ #endif
51+ strToExp content
52+ where
overlays/windows.nix+1
@@ -110,6 +110,7 @@ final: prev:
110110 conduit.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ];
111111 streaming-commons.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ];
112112 x509-system.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ];
113+ file-embed.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed.patch ];
113114 file-embed-lzma.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ];
114115
115116 # Set all of these to [], as these form the