Skip to content

Commit 99cd261

Browse files
committed
:sigh:
1 parent a5b702b commit 99cd261

File tree

5 files changed

+77
-7
lines changed

5 files changed

+77
-7
lines changed

overlays/bootstrap.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ in {
187187
# support R_X86_64_PC64 (ELF constant 24) - IMAGE_REL_AMD64_SREL32 (PE constant 14), which seems to appear with 9.6 more frequently, and
188188
# results in "unhandled PEi386 relocation type 14".
189189
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.10" ./patches/ghc/win-reloc-x86_64-pc64.patch)
190+
# ++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.10" ./patches/ghc/Win32-depends-on-mingwex.patch)
191+
# if the host system provides ucrt (e.g. wine with ucrtbase.dll), we may end up linking against symbols from ucrtbase, instead of msvcrt,
192+
# 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
193+
# by another crt.
194+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "8.10" "9.10" ./patches/ghc/win-linker-no-ucrt.patch)
195+
# Nixos/nixpkgs is mscvrt for now, thus we must disable ucrt in ghc, otherwise we end up with broken linking.
196+
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.10" ./patches/ghc/no-ucrt.patch)
190197
++ fromUntil "9.4.5" "9.4.8" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
191198
++ fromUntil "9.6.2" "9.8" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
192199
++ fromUntil "9.6.1" "9.10" ./patches/ghc/MR10116.patch
@@ -212,6 +219,7 @@ in {
212219
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10-aarch64-handle-none-rela.patch
213220
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-better-symbol-addr-debug.patch
214221
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch
222+
215223
;
216224
in ({
217225
ghc865 = final.callPackage ../compiler/ghc (traceWarnOld "8.6" {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/libraries/Win32/Win32.cabal b/libraries/Win32/Win32.cabal
2+
index e986b7e..603354f 100644
3+
--- a/libraries/Win32/Win32.cabal
4+
+++ b/libraries/Win32/Win32.cabal
5+
@@ -138,7 +138,7 @@ Library
6+
System.Win32.Time.Internal
7+
8+
extra-libraries:
9+
- "user32", "gdi32", "winmm", "advapi32", "shell32", "shfolder", "shlwapi", "msimg32", "imm32"
10+
+ "user32", "gdi32", "winmm", "advapi32", "shell32", "shfolder", "shlwapi", "msimg32", "imm32", "mingwex"
11+
ghc-options: -Wall
12+
include-dirs: include
13+
includes: "alphablend.h", "diatemp.h", "dumpBMP.h", "ellipse.h", "errors.h", "HsGDI.h", "HsWin32.h", "Win32Aux.h", "win32debug.h", "windows_cconv.h", "WndProc.h", "alignment.h"

overlays/patches/ghc/no-ucrt.patch

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
2+
index 5393363..4f5db98 100644
3+
--- a/libraries/ghc-prim/ghc-prim.cabal
4+
+++ b/libraries/ghc-prim/ghc-prim.cabal
5+
@@ -73,7 +73,7 @@ Library
6+
-- mingw32 which is required by mingwex.
7+
-- user32: provides access to apis to modify user components (UI etc)
8+
-- on Windows. Required because of mingw32.
9+
- extra-libraries: user32, mingw32, ucrt
10+
+ extra-libraries: user32, mingw32, msvcrt, mingwex
11+
12+
if os(linux)
13+
-- we need libm, but for musl and other's we might need libc, as libm
14+
diff --git a/m4/fp_setup_windows_toolchain.m4 b/m4/fp_setup_windows_toolchain.m4
15+
index 1f44a38..122a205 100644
16+
--- a/m4/fp_setup_windows_toolchain.m4
17+
+++ b/m4/fp_setup_windows_toolchain.m4
18+
@@ -86,7 +86,7 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
19+
# Signal that we are linking against UCRT with the _UCRT macro. This is
20+
# necessary to ensure correct behavior when MinGW-w64 headers are in the
21+
# header include path (#22159).
22+
- cflags="--rtlib=compiler-rt -D_UCRT"
23+
+ cflags=""
24+
CFLAGS="$cflags"
25+
CONF_CC_OPTS_STAGE1="$cflags"
26+
CONF_CC_OPTS_STAGE2="$cflags"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
2+
index c404992..fd060e4 100644
3+
--- a/rts/linker/PEi386.c
4+
+++ b/rts/linker/PEi386.c
5+
@@ -1132,6 +1132,11 @@ lookupSymbolInDLLs ( const SymbolName* lbl, ObjectCode *dependent )
6+
for (o_dll = opened_dlls; o_dll != NULL; o_dll = o_dll->next) {
7+
/* debugBelch("look in %ls for %s\n", o_dll->name, lbl); */
8+
9+
+ if (wcsncmp(o_dll->name,WSTR("ucrtbase.dll"),wcslen(WSTR("ucrtbase.dll"))) == 0) {
10+
+ IF_DEBUG(linker, debugBelch("warning: ignoring %s\n", o_dll->name));
11+
+ continue;
12+
+ }
13+
+
14+
sym = GetProcAddress(o_dll->instance, lbl+STRIP_LEADING_UNDERSCORE);
15+
if (sym != NULL) {
16+
/*debugBelch("found %s in %s\n", lbl+1,o_dll->name);*/

overlays/wine.nix

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ final: prev:
66
prev.lib.optionalAttrs (!prev.stdenv.hostPlatform.isDarwin) {
77
winePackages = prev.winePackages // {
88
minimal = prev.winePackages.minimal.overrideAttrs (oldAttrs: {
9-
name = "wine-5.4";
10-
version = "5.4";
11-
src = prev.fetchurl {
12-
url = "https://dl.winehq.org/wine/source/5.x/wine-5.4.tar.xz";
13-
sha256 = "sha256-Sz4rD/pUFfGZVA5gUcKMOXb86R6lv7LPSgmcJXMXBSw=";
14-
};
15-
patches = [] ++ [ ./patches/wine-add-dll-directory.patch ];
9+
# name = "wine-5.4";
10+
# version = "5.4";
11+
# src = prev.fetchurl {
12+
# url = "https://dl.winehq.org/wine/source/5.x/wine-5.4.tar.xz";
13+
# sha256 = "sha256-Sz4rD/pUFfGZVA5gUcKMOXb86R6lv7LPSgmcJXMXBSw=";
14+
# };
15+
# name = "wine-5.22";
16+
# version = "5.22";
17+
# src = prev.fetchurl {
18+
# url = "https://dl.winehq.org/wine/source/5.x/wine-5.22.tar.xz";
19+
# sha256 = "sha256-Cb0GyHyMl05q00UHzsh11yF+tW/Anfg41UU+DrvOTSE=";
20+
# };
21+
# patches = [ ./patches/wine-add-dll-directory.patch ];
22+
patches = oldAttrs.patches or [] ++ [ ./patches/wine-add-dll-directory.patch ];
1623
# Turning off the tests as there is a problem with the `schedsvc` test.
1724
# With recent nixpkgs both the IDL files generate `_c.c` files with
1825
# `handle_t rpc_handle` and that results in a linker error (duplicate symbols).

0 commit comments

Comments
 (0)