wine64Packages.unstable: Darwin compatibility fixes

- Wine 8.12 changed the implementation of `macdrv_get_gpus_from_metal`,
causing the patch used by nixpkgs to break. This patch splits that
patch up to apply cleanly depending on the version;
- Silence an implicit pointer to integer conversion warning due to the
above patch (required by the Clang 16 stdenv bump);
- Add the PCSC framework on Darwin, which is required as of Wine 8.14.

Wine 8.14 changes the implementation of `macdrv_get_gpus_from_metal`,
causing the patch to no longer apply cleanly. Splitting the patch allows
only the parts that are still needed to apply cleanly dependin gon the
Wine version being built.

authored by

Randy Eckenrode and committed by
Michael Raskin
bdf47492 0f361174

+39 -23
+16 -3
pkgs/applications/emulators/wine/base.nix
··· 90 ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ] 91 ++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ] 92 ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ 93 - CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration Security 94 ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon 95 ]) 96 ++ lib.optionals (stdenv.isLinux && !waylandSupport) (with pkgs.xorg; [ ··· 103 104 patches = [ ] 105 ++ lib.optionals stdenv.isDarwin [ 106 - # Wine requires `MTLDevice.registryID` for `winemac.drv`, but that property is not available 107 - # in the 10.12 SDK (current SDK on x86_64-darwin). Work around that by using selector syntax. 108 ./darwin-metal-compat.patch 109 # Wine requires `qos.h`, which is not included by default on the 10.12 SDK in nixpkgs. 110 ./darwin-qos.patch 111 ] 112 ++ patches'; 113 114 configureFlags = prevConfigFlags 115 ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
··· 90 ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ] 91 ++ lib.optionals (openglSupport && !stdenv.isDarwin) [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ] 92 ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ 93 + CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration PCSC Security 94 ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenCL Cocoa Carbon 95 ]) 96 ++ lib.optionals (stdenv.isLinux && !waylandSupport) (with pkgs.xorg; [ ··· 103 104 patches = [ ] 105 ++ lib.optionals stdenv.isDarwin [ 106 + # Wine uses `MTLDevice.registryID` in `winemac.drv`, but that property is not available in 107 + # the 10.12 SDK (current SDK on x86_64-darwin). That can be worked around by using selector 108 + # syntax. As of Wine 8.12, the logic has changed and uses selector syntax, but it still 109 + # uses property syntax in one place. The first patch is necessary only with older 110 + # versions of Wine. The second is needed on all versions of Wine. 111 + (lib.optional (lib.versionOlder version "8.12") ./darwin-metal-compat-pre8.12.patch) 112 ./darwin-metal-compat.patch 113 # Wine requires `qos.h`, which is not included by default on the 10.12 SDK in nixpkgs. 114 ./darwin-qos.patch 115 ] 116 ++ patches'; 117 + 118 + # Because the 10.12 SDK doesn’t define `registryID`, clang assumes the undefined selector returns 119 + # `id`, which is a pointer. This causes implicit pointer to integer errors in clang 15+. 120 + # The following post-processing step adds a cast to `uint64_t` before the selector invocation to 121 + # silence these errors. 122 + postPatch = lib.optionalString stdenv.isDarwin '' 123 + sed -e 's|\(\[[A-Za-z_][][A-Za-z_0-9]* registryID\]\)|(uint64_t)\1|' \ 124 + -i dlls/winemac.drv/cocoa_display.m 125 + ''; 126 127 configureFlags = prevConfigFlags 128 ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
+22
pkgs/applications/emulators/wine/darwin-metal-compat-pre8.12.patch
···
··· 1 + diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m 2 + --- a/dlls/winemac.drv/cocoa_display.m 3 + +++ b/dlls/winemac.drv/cocoa_display.m 4 + @@ -289,7 +289,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) 5 + * the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps 6 + * using the integrated GPU. This is the behavior of Windows on a Mac. */ 7 + primary_device = [MTLCreateSystemDefaultDevice() autorelease]; 8 + - if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, primary_device.registryID)) 9 + + if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, [primary_device registryID])) 10 + goto done; 11 + 12 + /* Hide the integrated GPU if the system default device is a dedicated GPU */ 13 + @@ -301,7 +301,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) 14 + 15 + for (i = 0; i < devices.count; i++) 16 + { 17 + - if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], devices[i].registryID)) 18 + + if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], [devices[i] registryID])) 19 + goto done; 20 + 21 + if (hide_integrated && devices[i].isLowPower) 22 +
+1 -20
pkgs/applications/emulators/wine/darwin-metal-compat.patch
··· 1 diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m 2 - index f64a6c0f6ad..6da0391e3fa 100644 3 --- a/dlls/winemac.drv/cocoa_display.m 4 +++ b/dlls/winemac.drv/cocoa_display.m 5 - @@ -289,7 +289,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) 6 - * the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps 7 - * using the integrated GPU. This is the behavior of Windows on a Mac. */ 8 - primary_device = [MTLCreateSystemDefaultDevice() autorelease]; 9 - - if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, primary_device.registryID)) 10 - + if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, (uint64_t)[primary_device registryID])) 11 - goto done; 12 - 13 - /* Hide the integrated GPU if the system default device is a dedicated GPU */ 14 - @@ -301,7 +301,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) 15 - 16 - for (i = 0; i < devices.count; i++) 17 - { 18 - - if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], devices[i].registryID)) 19 - + if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], (uint64_t)[devices[i] registryID])) 20 - goto done; 21 - 22 - if (hide_integrated && devices[i].isLowPower) 23 @@ -354,7 +354,7 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp 24 25 device = [CGDirectDisplayCopyCurrentMetalDevice(display_id) autorelease]; 26 if (device && [device respondsToSelector:@selector(registryID)]) 27 - ret = macdrv_get_gpu_info_from_registry_id(gpu, device.registryID); 28 - + ret = macdrv_get_gpu_info_from_registry_id(gpu, (uint64_t)[device registryID]); 29 30 done: 31 [pool release];
··· 1 diff --git a/dlls/winemac.drv/cocoa_display.m b/dlls/winemac.drv/cocoa_display.m 2 --- a/dlls/winemac.drv/cocoa_display.m 3 +++ b/dlls/winemac.drv/cocoa_display.m 4 @@ -354,7 +354,7 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp 5 6 device = [CGDirectDisplayCopyCurrentMetalDevice(display_id) autorelease]; 7 if (device && [device respondsToSelector:@selector(registryID)]) 8 - ret = macdrv_get_gpu_info_from_registry_id(gpu, device.registryID); 9 + + ret = macdrv_get_gpu_info_from_registry_id(gpu, [device registryID]); 10 11 done: 12 [pool release];