summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-07 13:15:50 +0800
committerGitHub <[email protected]>2024-08-07 13:15:50 +0800
commit354cbaf00470f1fdcaa4a6d131e286875e8a4cbf (patch)
treec63fd1f719629280652c90adf3fd1eed74bc36f6
parentb0524faed10267bfe351f79186c1cac649682223 (diff)
parente26ea1c31f9fd0733590c36db4b6f9003fae8547 (diff)
Merge pull request #5442 from SirLynix/patch-17
Don't treat x86_64 as cross on arm64 macOS
-rw-r--r--xmake/core/base/private/is_cross.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmake/core/base/private/is_cross.lua b/xmake/core/base/private/is_cross.lua
index 32fb7aae6..c395124ab 100644
--- a/xmake/core/base/private/is_cross.lua
+++ b/xmake/core/base/private/is_cross.lua
@@ -25,9 +25,10 @@ local os = require("base/os")
function is_cross(plat, arch)
plat = plat or os.subhost()
arch = arch or os.subarch()
- if os.host() == "windows" then
- local host_arch = os.arch()
+ local host_os = os.host()
+ if host_os == "windows" then
if plat == "windows" then
+ local host_arch = os.arch()
-- maybe cross-compilation for arm64 on x86/x64
if (host_arch == "x86" or host_arch == "x64") and arch == "arm64" then
return true
@@ -39,6 +40,14 @@ function is_cross(plat, arch)
elseif plat == "mingw" then
return false
end
+ elseif host_os == "macosx" then
+ if plat == "macosx" then
+ local host_arch = os.arch()
+ -- arm64 macOS can execute x86_64 (rosetta)
+ if host_arch == "arm64" and arch == "x86_64" then
+ return false
+ end
+ end
end
if plat ~= os.host() and plat ~= os.subhost() then
return true
@@ -46,6 +55,7 @@ function is_cross(plat, arch)
if arch ~= os.arch() and arch ~= os.subarch() then
return true
end
+ return false
end
return is_cross