From e498ce5b58993094b699b84d9744c77a19f36578 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 18 Nov 2025 15:14:57 +0800 Subject: [PATCH] dependencies/ui.py: Improve Vulkan detection on Windows There now exists a Windows Vulkan SDK for ARM64, and the latest Vulkan SDKs for x64 Windows also provides ARM64 libraries and binaries for cross-builds (and vice-versa). So, now we have the following in the Vulkan SDKs: * Bin-ARM64 and Lib-ARM64 in x64 Windows SDKs that contains ARM64 Vulkan binaries and libraries. * Bin-X64 and Lib-X64 in ARM64 Windows SDKs that contains x64 Vulkan binaries and libraries * SDKs after 1.4.x (or so) no longer ships 32-bit Windows binaries and libraries. This updates the Vulkan detection logic to account for these differences so that the correct library is picked up upon linking on Windows, especially when cross-compiling ARM64 binaries on x64 Windows, and vice versa, while maintaining compatibility with native and 32-bit builds. --- mesonbuild/dependencies/ui.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index f000b58dd460..566ba52dccd7 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -15,7 +15,6 @@ from ..mesonlib import ( Popen_safe, version_compare_many ) -from ..envconfig import detect_cpu_family from .base import DependencyException, DependencyMethods, DependencyTypeName, SystemDependency from .configtool import ConfigToolDependency @@ -190,10 +189,34 @@ def __init__(self, name: str, environment: 'Environment', kwargs: DependencyObje inc_dir = 'include' if self.env.machines[self.for_machine].is_windows(): lib_name = 'vulkan-1' - lib_dir = 'Lib32' + lib_dir = '' inc_dir = 'Include' - if detect_cpu_family(self.env.coredata.compilers.host) == 'x86_64': - lib_dir = 'Lib' + build_cpu = self.env.machines.build.cpu_family + host_cpu = self.env.machines.host.cpu_family + if build_cpu == 'x86_64': + if host_cpu == build_cpu: + lib_dir = 'Lib' + elif host_cpu == 'aarch64': + lib_dir = 'Lib-ARM64' + elif host_cpu == 'x86': + lib_dir = 'Lib32' + elif build_cpu == 'aarch64': + if host_cpu == build_cpu: + lib_dir = 'Lib' + elif host_cpu == 'x86_64': + lib_dir = 'Lib-x64' + elif host_cpu == 'x86': + lib_dir = 'Lib32' + elif build_cpu == 'x86': + if host_cpu == build_cpu: + lib_dir = 'Lib32' + if host_cpu == 'aarch64': + lib_dir = 'Lib-ARM64' + elif host_cpu == 'x86_64': + lib_dir = 'Lib' + + if lib_dir == '': + raise DependencyException(f'Target architecture \'{host_cpu}\' is not supported for this Vulkan SDK.') # make sure header and lib are valid inc_path = os.path.join(self.vulkan_sdk, inc_dir)