Description
Describe the bug
I've been trying to cross-compile a project from Linux to Windows, and noticed that several dependencies which depend on TH fail to compile in the same manner described in #1913.
There are a few examples, such as exceptions in TH code that reads from a file with file-embed, as in #1913. But for this issue I'll focus on just building aeson-typescript
, where the TH doesn't even do external IO.
This is on x86_64-linux
. I've tried with GHC 9.6.6 and GHC 9.8.4, which the current repro uses, and the latest Haskell.nix.
I think #2034 was meant to address these issues, but I think there might have been some regression. I'd note that the comment in overlays/wine.nix became out of date with #2034, which stopped pinning Wine. That comment mentioned Wine 5.4, but Wine on nixpkgs-unstable
is up to version 10.0 now.
Steps To Reproduce
git clone git@github.com:codedownio/aeson-typescript.git
cd aeson-typescript
nix build .#windows
The build fails with a message like this (which sort of suggests a locale issue?):
> wine: failed to open L"C:\\windows\\syswow64\\rundll32.exe": c0000135
> wine: configuration in L"/build" has been updated.
> Listening on port 6249
> iserv-proxy: getBin: Unknown encoding for constructor
> iserv-proxy-interpreter.exe:<socket:180>:hPutBuf:invalidargument(Invalid a
> rgument)
>
> src/Data/Aeson/TypeScript/Instances.hs:190:25: error: [GHC-87897]
> • Exception when trying to run compile-time code:
> {handle: <file descriptor: 25>}: GHCi.Message.remoteCall: end of file
> Code: Language.Haskell.TH.Quote.quoteExp
> i "{[k: string]: #{getTypeScriptType (Proxy :: Proxy a)}}"
> • In the quasi-quotation:
> [i|{[k: string]: #{getTypeScriptType (Proxy :: Proxy a)}}|]
> |
> 190 | getTypeScriptType _ = [i|{[k: string]: #{getTypeScriptType (Proxy :: Proxy a)}}|]
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> [ 8 of 12] Compiling Data.Aeson.TypeScript.Formatting ( src/Data/Aeson/TypeScript/Formatting.hs, dist/build/Data/Aeson/TypeScript/Formatting.o )
Expected behavior
The pkgsCross.mingwW64
version of the aeson-typescript
library should build successfully.
CC @amesgen and @angerman, I'd be very grateful for any help in figuring this out!
Activity
angerman commentedon Feb 6, 2025
@thomasjm I hope to have some time to investigate this next week 😅
thomasjm commentedon Feb 6, 2025
Thank you!
thomasjm commentedon Feb 20, 2025
Any chance you'll be able to look at this soon @angerman? I'd love to be able to cross-compile my projects rather than use an actual Windows machine...
angerman commentedon Feb 21, 2025
I did, but haven't gotten a solution yet :-/
unknownsymbol 'expm1'
on mingw32 #2335hamishmack commentedon Apr 8, 2025
Please try replacing
pkgsCross.mingwW64
withpkgsCross.ucrt64
.thomasjm commentedon Apr 8, 2025
Thanks @hamishmack -- just tried it and got the same result. Full output here:
https://gist.github.com/thomasjm/8ccc2ee06dcb9f66bcbe178fb6f9fb99
thomasjm commentedon Apr 16, 2025
Hi all -- I saw on #2335 that this was described as "the dreaded" issue haha. I'd like to help push it forward if I can. Any chance you could write down what you found out about the problem so far? To me it initially looked like some kind of encoding issue when communicating with this
iserv
thing.hamishmack commentedon Apr 17, 2025
I've done some digging, but I am not sure what is going on.
The issue can be reproduced in the haskell.nix repo with:
Replacing
compiler-nix-name
gives:I'm not sure if there was a regression in GHC 9.8 that was fixed by the time 9.12.2 was released or if there is a patch we are not applying to GHC 9.8 and 9.10 that we do apply to 9.6 and 9.12.
[-]Possible regression of cross-compiling TH with mingwW64[/-][+]Regression of cross-compiling TH[/+]thomasjm commentedon May 14, 2025
I just edited the title to be more general because I found this doesn't just affect Windows targets; it seems to affect all cross-compilation like
aarch64-multiplatform
.ucrt64
) cross compilation on GHC 9.6/9.8/9.10 #2361thomasjm commentedon Jun 10, 2025
FWIW, I tried my repro again after #2385 landed and got a slightly different failure. The relevant logs are:
After this, it just hangs.