Closed
Description
Describe the bug
Reading files during TH (e.g. via file-embed
) (EDIT: this is just an example, also happens with much more mundane things, see #1913 (comment)) fails when cross-compiling to mingwW64 from x86_64-linux on GHC 9.4 and 9.6.
main :: IO ()
main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
Steps To Reproduce
Minimal reproducible example: https://github.com/amesgen/stuff/tree/haskell.nix-mingwW64-TH-readFile-again
Concretely:
$ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc944
...
/nix/store/f1yzg91kr20alxcpqwikxwv708irs7xi-iserv-wrapper/bin/iserv-wrapper: line 31: 200 Segmentation fault (core dumped) WINEDLLOVERRIDES="winemac.drv=d" WINEDEBUG=warn-all,fixme-all,-menubuilder,-mscoree,-ole,-secur32,-winediag WINEPREFIX=$TMP /nix/store/90hdb8v389sxv4xbxgv80w36lfbg1c78-wine-5.4/bin/wine64 $REMOTE_ISERV/iserv-proxy-interpreter.exe tmp $PORT
app/Main.hs:8:17: error:
• Exception when trying to run compile-time code:
ghc-iserv terminated (1)
Code: (TH.lift =<< TH.runIO (readFile "app/foo.txt"))
• In the untyped splice:
$(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
|
8 | main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc961
...
iserv-proxy-interpreter.exe: Could not load Object Code /nix/store/xg4301nc9ygcpkpw8d5rp0wr81n299p6-x86_64-w64-mingw32-ghc-9.6.1/lib/x86_64-windows-ghc-9.6.1/ghc-prim-0.10.0/HSghc-prim-0.10.0.o.
<no location info>: error: unable to load unit `ghc-prim-0.10.0'
Expected behavior
It should compile fine, as it does e.g. on 9.2.
$ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc927 # works fine
Additional context
Maybe it is again due to a Wine version problem, cf. #1487?