Skip to content

Commit 354cbaf

Browse files
authored
Merge pull request #5442 from SirLynix/patch-17
Don't treat x86_64 as cross on arm64 macOS
2 parents b0524fa + e26ea1c commit 354cbaf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

xmake/core/base/private/is_cross.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ local os = require("base/os")
2525
function is_cross(plat, arch)
2626
plat = plat or os.subhost()
2727
arch = arch or os.subarch()
28-
if os.host() == "windows" then
29-
local host_arch = os.arch()
28+
local host_os = os.host()
29+
if host_os == "windows" then
3030
if plat == "windows" then
31+
local host_arch = os.arch()
3132
-- maybe cross-compilation for arm64 on x86/x64
3233
if (host_arch == "x86" or host_arch == "x64") and arch == "arm64" then
3334
return true
@@ -39,13 +40,22 @@ function is_cross(plat, arch)
3940
elseif plat == "mingw" then
4041
return false
4142
end
43+
elseif host_os == "macosx" then
44+
if plat == "macosx" then
45+
local host_arch = os.arch()
46+
-- arm64 macOS can execute x86_64 (rosetta)
47+
if host_arch == "arm64" and arch == "x86_64" then
48+
return false
49+
end
50+
end
4251
end
4352
if plat ~= os.host() and plat ~= os.subhost() then
4453
return true
4554
end
4655
if arch ~= os.arch() and arch ~= os.subarch() then
4756
return true
4857
end
58+
return false
4959
end
5060

5161
return is_cross

0 commit comments

Comments
 (0)