Skip to content

Regression when reading files via TH in mingwW64 cross compilation #1487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amesgen opened this issue May 28, 2022 · 1 comment · Fixed by #1508
Closed

Regression when reading files via TH in mingwW64 cross compilation #1487

amesgen opened this issue May 28, 2022 · 1 comment · Fixed by #1508

Comments

@amesgen
Copy link
Member

amesgen commented May 28, 2022

Reading a file at compile time via TH worked before #1450, but does now error, i.e.

import qualified Language.Haskell.TH.Syntax as TH

main :: IO ()
main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))

fails to compile with message

[1 of 1] Compiling Main             ( app/Main.hs, dist/build/stuff/stuff-tmp/Main.o )
---> Starting remote-iserv on port 9094
---| remote-iserv should have started on 9094
0050:err:systray:initialize_systray Could not create tray window
0084:err:setupapi:SetupDefaultQueueCallbackW copy error 1812 L"@C:\\windows\\system32\\drivers\\wineusb.sys,-1" -> L"C:\\windows\\inf\\wineusb.inf"
wine: configuration in L"/build" has been updated.
Listening on port 9094
0024:err:msvcrt:_invalid_parameter (null):0 (null): (null) 0

app/Main.hs:8:17: error:
    • Exception when trying to run compile-time code:
        app/foo.txt: hGetContents: invalid argument (Bad file descriptor)
      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"))
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---> killing remote-iserv...

Minimal reproducible example

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

This fails:

nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile \
  --override-input haskellNix github:input-output-hk/haskell.nix/82bc94581865b098985890745c371ef6ce67f1ce

This succeeds:

nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile \
  --override-input haskellNix github:input-output-hk/haskell.nix/e00ff6591a2dc86bc021046a213bd5f392a5659f

where

 $ git log -2 --oneline  82bc94581865b098985890745c371ef6ce67f1ce
82bc9458 Fix ghc 9 windows cross compilation (#1450)
e00ff659 Update Hackage and Stackage
@ramirez7
Copy link
Contributor

I was able to repro this as well - I also tried file-embed and it too fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants