Skip to content

Commit a0db85a

Browse files
committed
improve llvm cross-compilation
1 parent 285b19a commit a0db85a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

xmake/toolchains/llvm/check.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function main(toolchain)
8484
end
8585

8686
-- find cross toolchain from external envirnoment
87-
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross})
87+
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir})
8888
if not cross_toolchain then
8989
-- find it from packages
9090
for _, package in ipairs(toolchain:packages()) do
@@ -98,7 +98,7 @@ function main(toolchain)
9898
end
9999
end
100100
if cross_toolchain then
101-
toolchain:config_set("cross", cross_toolchain.cross)
101+
toolchain:config_set("cross", cross)
102102
toolchain:config_set("bindir", cross_toolchain.bindir)
103103
toolchain:config_set("sdkdir", cross_toolchain.sdkdir)
104104
toolchain:configs_save()
@@ -116,3 +116,4 @@ function main(toolchain)
116116
end
117117
return cross_toolchain
118118
end
119+

xmake/toolchains/llvm/xmake.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ toolchain("llvm")
5959
end
6060
toolchain:add("ldflags", "-fuse-ld=lld")
6161
toolchain:add("shflags", "-fuse-ld=lld")
62-
elseif toolchain:is_arch("x86_64", "x64") then
63-
march = "-m64"
64-
elseif toolchain:is_arch("i386", "x86") then
65-
march = "-m32"
6662
elseif toolchain:is_plat("cross") then
6763
local sysroot
6864
local sdkdir = toolchain:sdkdir()
@@ -90,6 +86,10 @@ toolchain("llvm")
9086
toolchain:add("ldflags", "--sysroot=" .. sysroot)
9187
toolchain:add("shflags", "--sysroot=" .. sysroot)
9288
end
89+
elseif toolchain:is_arch("x86_64", "x64") then
90+
march = "-m64"
91+
elseif toolchain:is_arch("i386", "x86") then
92+
march = "-m32"
9393
end
9494
if march then
9595
toolchain:add("cxflags", march)
@@ -129,3 +129,4 @@ toolchain("llvm")
129129
toolchain:add("runenvs", "PATH", bindir)
130130
end
131131
end)
132+

0 commit comments

Comments
 (0)