From 83a310e5cef956ba965c6bf0d17b1d83fe1c4e63 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 26 Aug 2024 10:52:01 +0200 Subject: [PATCH] Detect "native" host architecture when running in x86 emulation on Windows on ARM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Creator is run as an x64 executable on a Windows on ARM machine, the auto detection of debuggers and compilers will not work as expected without this patch. Change-Id: I8b0b303b1db097f8cd95bb419c6a21b9a15e1ac8 Reviewed-by: David Schulz Reviewed-by: Kai Köhne --- src/libs/utils/hostosinfo.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/hostosinfo.cpp b/src/libs/utils/hostosinfo.cpp index 717dc900cd8..d81e5044875 100644 --- a/src/libs/utils/hostosinfo.cpp +++ b/src/libs/utils/hostosinfo.cpp @@ -31,7 +31,23 @@ bool HostOsInfo::m_useOverrideFileNameCaseSensitivity = false; OsArch HostOsInfo::hostArchitecture() { - static const OsArch arch = osArchFromString(QSysInfo::currentCpuArchitecture()); +#ifdef Q_OS_WIN + // Workaround for Creator running in x86 emulation mode on ARM machines + static const OsArch arch = []() { + const HANDLE procHandle = GetCurrentProcess(); + ushort processMachine; + ushort nativeMachine; + if (IsWow64Process2(procHandle, &processMachine, &nativeMachine) + && nativeMachine == IMAGE_FILE_MACHINE_ARM64) { + return OsArchArm64; + } + + return osArchFromString(QSysInfo::currentCpuArchitecture()); + }(); +#else + static const OsArch arch = osArchFromString(QSysInfo::currentCpuArchitecture()); +#endif + return arch; }