Skip to content

Fix Windows and GHC/ucrt. #2034

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

Merged
merged 10 commits into from
Sep 8, 2023
Merged

Fix Windows and GHC/ucrt. #2034

merged 10 commits into from
Sep 8, 2023

Conversation

angerman
Copy link
Collaborator

@angerman angerman commented Aug 26, 2023

GHC 9.4+ GHC uses ucrt and the llvm toolchain by default on windows. The one we have in nixpkgs is gcc and msvcrt based. A ucrt/llvm Pull Request was reverted in nixpkgs.
As such we now switch GHC back to using msvcrt for the time being. I've had lengthy discussions with Tamar about this, and it will be safe for now; we will eventually move to ucrt.

Wine in 5.5+ also started using ucrt for some libraries as such wine caused ucrtbase.dll to be loaded transitively and GHC ended up resolving symbols into ucrtbase.dll instead of msvcrt.dll, thus leading to all kinds of misfeatures (different file handles, errno, ...).

As such we now live in a msvcrt universe again in haskell.nix until we have ucrt in nixpkgs and can consider switching.

@angerman angerman requested a review from hamishmack August 26, 2023 08:53
@angerman angerman self-assigned this Aug 26, 2023
@angerman
Copy link
Collaborator Author

Also includes #1970 now.

hamishmack and others added 4 commits September 7, 2023 07:55
Fixes errors like this when trying to load DLLs into template haskell code with GHC 9.4 and above:

```
iserv-proxy-interpreter.exe: addLibrarySearchPath: \\?\Z:\nix\store\gjsf5jazfbfv21hvvgf1amd5rdx3ycf3-x86_64-w64-mingw32-ghc-9.4.3\lib\x86_64-windows-ghc-9.4.3\ghc-bignum-1.3 (Win32 error 87): Invalid parameter.
```

These errors arise with GHC 9.4 and above because it uses UNC paths to avoid limits on path length.  The `RtlDetermineDosPathNameType_U` function classifies these as a `DEVICE_PATH` and `LdrAddDllDirectory` gives up at that point.
@angerman angerman force-pushed the angerman/fix-win-reloc branch from 99cd261 to 1d559c9 Compare September 7, 2023 07:59
Nixpkgs `mingw64` is a msvcrt based toolchain. GHC 9.4+ moved on
to a ucrt based toolchain. We can hover reverse this change in GHC
and keep using msvcrt for now.

We also need to prevent the linker for linking ucrt, as that is
is incompatible with ucrt. By doing so we can also upgrade to a
newer wine, which contains ucrt libs. This would previously have
thrown our TH logic off.
@angerman angerman force-pushed the angerman/fix-win-reloc branch from 1d559c9 to 1ea1a3b Compare September 7, 2023 08:07
@angerman angerman changed the title Add windows R_X86_64_PC64 relocation support Fix Windows and GHC/ucrt. Sep 7, 2023
@angerman angerman merged commit 3e4262c into master Sep 8, 2023
@angerman angerman deleted the angerman/fix-win-reloc branch September 8, 2023 07:49
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 this pull request may close these issues.

2 participants