Skip to content

Patch wine to fix addDllDirectory #1970

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
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ in {
++ fromUntil "9.4.5" "9.4.6" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
++ fromUntil "9.6.2" "9.8" ./patches/ghc/ghc-9.4.5-include-order-fix.patch
++ fromUntil "9.6.1" "9.8" ./patches/ghc/MR10116.patch
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.6.1" "9.8" ./patches/ghc-image-rel-amd64-srel32.patch)
++ final.lib.optionals (final.stdenv.buildPlatform == final.stdenv.targetPlatform) (fromUntil "9.4.1" "9.6" ./patches/ghc/hadrian-build-deriveConstants-genprimopcode-ghc94.patch)
++ final.lib.optionals (final.stdenv.buildPlatform == final.stdenv.targetPlatform) (fromUntil "9.6.1" "9.8" ./patches/ghc/hadrian-build-deriveConstants-genprimopcode.patch)
++ final.lib.optionals (final.stdenv.targetPlatform.isGhcjs) (fromUntil "9.6.1" "9.8" ./patches/ghc/ghc-9.6-Merge-libiserv-with-ghci.patch)
Expand Down
21 changes: 21 additions & 0 deletions overlays/patches/ghc-image-rel-amd64-srel32.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
From 28607c22f968587177c8a0d25f2e7a64b4ae5be8 Mon Sep 17 00:00:00 2001
From: Moritz Angermann <[email protected]>
Date: Wed, 31 May 2023 12:30:39 +0800
Subject: [PATCH] Update PEi386.c

---
rts/linker/PEi386.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index b5134235b02..682b4ec7e83 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -2038,6 +2038,7 @@ ocResolve_PEi386 ( ObjectCode* oc )
}
case 2: /* R_X86_64_32 (ELF constant 10) - IMAGE_REL_AMD64_ADDR32 (PE constant 2) */
case 3: /* IMAGE_REL_AMD64_ADDR32NB (PE constant 3) */
+ case 14: /* R_X86_64_PC64 (ELF constant 24) - IMAGE_REL_AMD64_SREL32 (PE constant 14) */
case 17: /* R_X86_64_32S ELF constant, no PE mapping. See note [ELF constant in PE file] */
{
uint64_t v;
13 changes: 13 additions & 0 deletions overlays/patches/wine-add-dll-directory.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 85eb2976807..36d92b32d1c 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -4015,7 +4015,7 @@ NTSTATUS WINAPI LdrAddDllDirectory( const UNICODE_STRING *dir, void **cookie )
struct dll_dir_entry *ptr;
DOS_PATHNAME_TYPE type = RtlDetermineDosPathNameType_U( dir->Buffer );

- if (type != ABSOLUTE_PATH && type != ABSOLUTE_DRIVE_PATH)
+ if (type != ABSOLUTE_PATH && type != ABSOLUTE_DRIVE_PATH && type != DEVICE_PATH )
return STATUS_INVALID_PARAMETER;

status = RtlDosPathNameToNtPathName_U_WithStatus( dir->Buffer, &nt_name, NULL, NULL );
23 changes: 6 additions & 17 deletions overlays/wine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@
# files from TH code) for GHC built with msvcrt (ghc<9.6).
# This will inevitably replace *any* wine version. Thus this might not really be what we ultimately want.
# Wine 5.4 does not build on macOS so that is not pinned and TH code will probably break.
final: prev:
prev.lib.optionalAttrs (!prev.stdenv.hostPlatform.isDarwin) {
winePackages = prev.winePackages // {
minimal = prev.winePackages.minimal.overrideAttrs (oldAttrs: {
name = "wine-5.4";
version = "5.4";
src = prev.fetchurl {
url = "https://dl.winehq.org/wine/source/5.x/wine-5.4.tar.xz";
sha256 = "sha256-Sz4rD/pUFfGZVA5gUcKMOXb86R6lv7LPSgmcJXMXBSw=";
};
patches = [];
# Turning off the tests as there is a problem with the `schedsvc` test.
# With recent nixpkgs both the IDL files generate `_c.c` files with
# `handle_t rpc_handle` and that results in a linker error (duplicate symbols).
configureFlags = oldAttrs.configureFlags or [] ++ ["--disable-tests"];
});
};
final: prev: {
winePackages = prev.winePackages // {
minimal = prev.winePackages.minimal.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [] ++ [ ./patches/wine-add-dll-directory.patch ];
});
};
}
3 changes: 2 additions & 1 deletion test/th-dlls/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ in recurseIntoAttrs {
meta.disabled = stdenv.hostPlatform.isGhcjs ||
# TH breaks for ghc 9.4.3 cross compile for windows if the library even
# just depends on the `text` package (this may be related to the C++ dependency).
(stdenv.hostPlatform.isWindows && __elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944" "ghc945" "ghc96020230302" "ghc961" "ghc962"]) ||
# TODO: update above comment if we get this working.
# (stdenv.hostPlatform.isWindows && __elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944" "ghc945" "ghc96020230302" "ghc961" "ghc962"]) ||
# Similar problem on macOS
(stdenv.hostPlatform.isDarwin && __elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944" "ghc945" "ghc96020230302" "ghc961" "ghc962"]) ||
# On aarch64 this test also breaks form musl builds (including cross compiles on x86_64-linux)
Expand Down