Skip to content

Commit 2ebea58

Browse files
hamishmackangerman
andauthored
Try ucrt64 (#2083)
* Try ucrt64 * ifdLevel 1 * ifdLevel 2 * ifdLevel 3 * Fix mingw_w64_pthreads for ucrt * Sigh * ifdLevel 0 * Update ci.nix * ifdLevel 2 * ifdLevel 3 * disable th-dll for ucrt --------- Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
1 parent 9fa08be commit 2ebea58

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

ci.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc947" "ghc963" (ghc980X nixpkgs) (ghc99X nixpkgs)])
103103
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
104104
inherit (lib.systems.examples) mingwW64;
105+
} // lib.optionalAttrs (nixpkgsName == "unstable"
106+
&& ((system == "x86_64-linux" && builtins.elem compiler-nix-name ["ghc947" "ghc963" (ghc980X nixpkgs) (ghc99X nixpkgs)])
107+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
108+
inherit (lib.systems.examples) ucrt64;
105109
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc947" "ghc963" (ghc980X nixpkgs) (ghc99X nixpkgs)]) {
106110
# Musl cross only works on linux
107111
# aarch64 cross only works on linux

overlays/bootstrap.nix

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,15 @@ in {
206206
# if the host system provides ucrt (e.g. wine with ucrtbase.dll), we may end up linking against symbols from ucrtbase, instead of msvcrt,
207207
# thus leading to broken code. E.g. the handles we create and hand to wine will all be busted, because they come from one and are processed
208208
# by another crt.
209-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "8.10" "9.8" ./patches/ghc/win-linker-no-ucrt.patch)
210-
# Nixos/nixpkgs is mscvrt for now, thus we must disable ucrt in ghc, otherwise we end up with broken linking.
211-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.6" ./patches/ghc/no-ucrt-9.4.patch)
212-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.1" "9.6.3" ./patches/ghc/no-ucrt-9.6.patch)
213-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.3" "9.8" ./patches/ghc/no-ucrt-9.6.3.patch)
214-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.8" "9.9" ./patches/ghc/no-ucrt-9.8.patch)
215-
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.9" "9.10" ./patches/ghc/no-ucrt-9.9.patch)
209+
++ final.lib.optionals (final.stdenv.targetPlatform.libc != "ucrt") (
210+
final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "8.10" "9.8" ./patches/ghc/win-linker-no-ucrt.patch)
211+
# Nixos/nixpkgs is mscvrt for now, thus we must disable ucrt in ghc, otherwise we end up with broken linking.
212+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.6" ./patches/ghc/no-ucrt-9.4.patch)
213+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.1" "9.6.3" ./patches/ghc/no-ucrt-9.6.patch)
214+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.3" "9.8" ./patches/ghc/no-ucrt-9.6.3.patch)
215+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.8" "9.9" ./patches/ghc/no-ucrt-9.8.patch)
216+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.9" "9.10" ./patches/ghc/no-ucrt-9.9.patch)
217+
)
216218
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.7" "9.5" ./patches/ghc/revert-289547580b6f2808ee123f106c3118b716486d5b.patch)
217219
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.3" "9.10" ./patches/ghc/revert-289547580b6f2808ee123f106c3118b716486d5b.patch)
218220
# the following is needed for cardano-prelude as it uses closure_sizeW :-/
@@ -1020,8 +1022,9 @@ in {
10201022

10211023
bootPkgs = bootPkgsGhc94 // {
10221024
ghc = if final.stdenv.buildPlatform != final.stdenv.targetPlatform
1023-
then final.buildPackages.buildPackages.haskell-nix.compiler.ghc962
1024-
else final.buildPackages.buildPackages.haskell.compiler.ghc962
1025+
then final.buildPackages.buildPackages.haskell-nix.compiler.ghc963
1026+
else final.buildPackages.buildPackages.haskell.compiler.ghc963
1027+
or final.buildPackages.buildPackages.haskell.compiler.ghc962
10251028
or final.buildPackages.buildPackages.haskell.compiler.ghc945
10261029
or final.buildPackages.buildPackages.haskell.compiler.ghc944
10271030
or final.buildPackages.buildPackages.haskell.compiler.ghc943;

overlays/mingw_w64.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ let
6969
################################################################################
7070
# Build logic (TH support via remote iserv via wine)
7171
#
72-
setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals hostPlatform.isWindows [
72+
setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals hostPlatform.isWindows ([
7373
"-fexternal-interpreter"
7474
"-pgmi" "${wineIservWrapper}/bin/iserv-wrapper"
7575
# TODO: this should be automatically injected based on the extraLibrary.
7676
"-L${mingw_w64_pthreads}/lib"
7777
"-L${mingw_w64_pthreads}/bin"
7878
"-L${gmp}/lib"
79-
]);
79+
]));
8080

8181
################################################################################
8282
# Test logic via wine

overlays/patches/ghc/win-add-tzset-to-rtssyms.patch

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
22
index 10efb2a..d8ea070 100644
33
--- a/rts/RtsSymbols.c
44
+++ b/rts/RtsSymbols.c
5-
@@ -163,7 +163,9 @@ extern char **environ;
5+
@@ -163,7 +163,11 @@ extern char **environ;
66
SymI_HasProto(__mingw_vfprintf) \
77
/* ^^ Need to figure out why this is needed. */ \
88
SymI_HasProto(closure_sizeW_) \
99
- /* ^^ This one needed for cardano-prelude m( */
1010
+ /* ^^ This one needed for cardano-prelude m( */ \
11+
+ SymI_NeedsProto(_tzset) \
12+
+ /* ^^ This one needed for time, tzset deprecated */\
1113
+ SymI_NeedsProto(tzset) \
1214
+ /* ^^ This one needed for unix-time */
1315
#else

overlays/windows.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ final: prev:
1717
mfpr = if !prev.stdenv.hostPlatform.isWindows then prev.mpfr else prev.mfpr.overrideAttrs (drv: {
1818
configureFlags = (drv.configureFlags or []) ++ [ "--enable-static --disable-shared" ];
1919
});
20+
} // prev.lib.optionalAttrs (prev.stdenv.hostPlatform.isWindows && prev.stdenv.hostPlatform.libc == "ucrt") {
21+
windows = prev.windows // {
22+
# TODO update stdenv.cc so that the wrapper adds -D_UCRT for libc=="ucrt"
23+
mingw_w64_pthreads = prev.windows.mingw_w64_pthreads.overrideAttrs { CPPFLAGS = "-D_UCRT"; };
24+
};
2025
} // {
2126
libmpc = if !prev.stdenv.hostPlatform.isWindows then prev.libmpc else prev.libmpc.overrideAttrs (drv: {
2227
configureFlags = (drv.configureFlags or []) ++ [ "--enable-static --disable-shared" ];

test/th-dlls/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ in recurseIntoAttrs {
2424
# the macOS linker tries to load `clang++` :facepalm:
2525
(stdenv.hostPlatform.isDarwin && compareGhc "9.4.0" >= 0) ||
2626
# On aarch64 this test also breaks form musl builds (including cross compiles on x86_64-linux)
27-
(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isMusl);
27+
(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isMusl) ||
28+
# broken on ucrt64 windows
29+
(stdenv.hostPlatform.libc == "ucrt")
30+
;
2831

2932
ifdInputs = {
3033
inherit (project true) plan-nix;

0 commit comments

Comments
 (0)