Skip to content

Regression when reading files via TH in windows (ucrt64) cross compilation on GHC 9.6/9.8/9.10 #2361

Open
@amesgen

Description

@amesgen

Since #2354, reading files via TemplateHaskell for Windows cross-compilation (ucrt64; mingwW64 is broken before/after #2354) fails:

import qualified Language.Haskell.TH.Syntax as TH

main :: IO ()
main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
stuff-exe-stuff-x86_64-w64-mingw32> [1 of 1] Compiling Main             ( app/Main.hs, dist/build/stuff/stuff-tmp/Main.o )
stuff-exe-stuff-x86_64-w64-mingw32> ---> Starting iserv-proxy-interpreter.exe on port 6018
stuff-exe-stuff-x86_64-w64-mingw32> To re-use the same wine-prefix and remote-iserv, set the following environment variables:
stuff-exe-stuff-x86_64-w64-mingw32> export WINEPREFIX=/build/tmp.16k3RVb3C6
stuff-exe-stuff-x86_64-w64-mingw32> export REMOTE_ISERV=/build/tmp.ZABjVoLRvB
stuff-exe-stuff-x86_64-w64-mingw32> ---| iserv-proxy-interpreter.exe should have started on 6018
stuff-exe-stuff-x86_64-w64-mingw32> 004c:err:vulkan:vulkan_init_once Wine was built without Vulkan support.
stuff-exe-stuff-x86_64-w64-mingw32> 004c:err:systray:initialize_systray Could not create tray window
stuff-exe-stuff-x86_64-w64-mingw32> 0094:err:setupapi:SetupDefaultQueueCallbackW copy error 1812 L"@C:\\windows\\system32\\drivers\\wineusb.sys,-1" -> L"C:\\windows\\inf\\wineusb.inf"
stuff-exe-stuff-x86_64-w64-mingw32> wine: failed to open L"C:\\windows\\syswow64\\rundll32.exe": c0000135
stuff-exe-stuff-x86_64-w64-mingw32> 002c:err:setupapi:do_file_copyW Unsupported style(s) 0x10
stuff-exe-stuff-x86_64-w64-mingw32> 00f8:err:ntoskrnl:ZwLoadDriver failed to create driver L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\winebth": c00000e5
stuff-exe-stuff-x86_64-w64-mingw32> 002c:err:setupapi:SetupDiInstallDevice Failed to start service L"winebth" for device L"ROOT\\WINE\\WINEBTH", error 1359.
stuff-exe-stuff-x86_64-w64-mingw32> 002c:err:setupapi:SetupDiInstallDevice Failed to control service L"winebth" for device L"ROOT\\WINE\\WINEBTH", error 1062.
stuff-exe-stuff-x86_64-w64-mingw32> 002c:err:setupapi:do_file_copyW Unsupported style(s) 0x10
stuff-exe-stuff-x86_64-w64-mingw32> 0120:err:setupapi:do_file_copyW Unsupported style(s) 0x10
stuff-exe-stuff-x86_64-w64-mingw32> 0120:err:setupapi:do_file_copyW Unsupported style(s) 0x10
stuff-exe-stuff-x86_64-w64-mingw32> Listening on port 6018
stuff-exe-stuff-x86_64-w64-mingw32>
stuff-exe-stuff-x86_64-w64-mingw32> app/Main.hs:8:17: error: [GHC-87897]
stuff-exe-stuff-x86_64-w64-mingw32>     • Exception when trying to run compile-time code:
stuff-exe-stuff-x86_64-w64-mingw32>         app/foo.txt: hGetContents: invalid argument (Bad file descriptor)
stuff-exe-stuff-x86_64-w64-mingw32>       Code: (TH.lift =<< TH.runIO (readFile "app/foo.txt"))
stuff-exe-stuff-x86_64-w64-mingw32>     • In the untyped splice:
stuff-exe-stuff-x86_64-w64-mingw32>         $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
stuff-exe-stuff-x86_64-w64-mingw32>   |
stuff-exe-stuff-x86_64-w64-mingw32> 8 | main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
stuff-exe-stuff-x86_64-w64-mingw32>   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
stuff-exe-stuff-x86_64-w64-mingw32> ---> killing iserv-proxy-interpreter.exe...

This error occurs with GHC 9.6.7 and GHC 9.8.4 and 9.10.2; with 9.12.2, it seems to work fine.

Minimal reproducible example

https://github.com/amesgen/stuff/tree/haskell.nix-windows-TH-readFile

008e8ccf Bump nixpkgs pins (#2354)
e9854532 Update Hackage and Stackage

Running this command reproduces the bug, using haskell.nix at 008e8cc:

nix build github:amesgen/stuff/haskell.nix-windows-TH-readFile#bad

This command runs with haskell.nix at e985453, which works fine, demonstrating that #2354 introduced the regression:

nix build github:amesgen/stuff/haskell.nix-windows-TH-readFile#good

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions