Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f318f5

Browse files
committed
(llvm) add runtime dirs to runenvs (for asan and libunwind)
1 parentfb9ef47 commit8f318f5

File tree

4 files changed

+67
-37
lines changed

4 files changed

+67
-37
lines changed

‎xmake/modules/core/tools/clang.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function nf_runtime(self, runtime, opt)
227227
-- @see https://discourse.llvm.org/t/improve-autolinking-of-compiler-rt-and-libc-on-windows-with-lld-link/71392/10
228228
-- and need manual setting of libc++ headerdirectory
229229
-- @see https://github.com/llvm/llvm-project/issues/79647
230-
localllvm_dirs=toolchain_utils.get_llvm_dirs(self)
230+
localllvm_dirs=toolchain_utils.get_llvm_dirs(self:toolchain(),self:toolchain():sdkdir())
231231

232232
ifself:is_plat("windows")andruntime=="c++_shared"then
233233
ifllvm_dirs.binthen

‎xmake/modules/private/utils/toolchain.lua‎

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ end
185185
function_get_llvm_resourcedir(toolchain)
186186
localllvm_resourcedir=_g._LLVM_resourceDIR
187187
ifllvm_resourcedir==nilthen
188-
localoutdata=try {function()returnos.iorunv(toolchain:get("cc"), {"-print-resource-dir"}, {envs=toolchain:runenvs()})end }
188+
localoutdata=try {function()returnos.iorunv(toolchain:tool("cc"), {"-print-resource-dir"}, {envs=toolchain:runenvs()})end }
189189
ifoutdatathen
190190
llvm_resourcedir=path.normalize(outdata:trim())
191191
ifnotos.isdir(llvm_resourcedir)then
@@ -198,10 +198,10 @@ function _get_llvm_resourcedir(toolchain)
198198
end
199199

200200
-- get llvm sdk root directory
201-
function_get_llvm_rootdir(self)
201+
function_get_llvm_rootdir(toolchain)
202202
localllvm_rootdir=_g._LLVM_ROOTDIR
203203
ifllvm_rootdir==nilthen
204-
localresourcedir=_get_llvm_resourcedir(self)
204+
localresourcedir=_get_llvm_resourcedir(toolchain)
205205
ifresourcedirthen
206206
llvm_rootdir=path.normalize(path.join(resourcedir,"..","..",".."))
207207
ifnotos.isdir(llvm_rootdir)then
@@ -214,40 +214,50 @@ function _get_llvm_rootdir(self)
214214
end
215215

216216
-- find compiler-rt dir
217-
function_get_llvm_compiler_win_rtdir_and_link(self,target)
217+
function_get_llvm_compiler_rtdir_and_link(toolchain)
218218
import("lib.detect.find_tool")
219219

220-
localcc=self:get("cc")
220+
localcc=toolchain:tool("cc")
221221
localcc_tool=find_tool(cc, {version=true})
222222
ifcc_toolandcc_tool.versionthen
223-
localresdir=_get_llvm_resourcedir(self)
223+
localresdir=_get_llvm_resourcedir(toolchain)
224224
ifresdirthen
225225
localres_libdir=path.join(resdir,"lib")
226226
-- when -DLLVM_ENABLE_TARGET_RUNTIME_DIR=OFF rtdir is windows/ and rtlink is clang_rt.builtinsi_<arch>.lib
227227
-- when ON rtdir is windows/<target-triple> and rtlink is clang_rt.builtins.lib
228-
localtarget_triple=_get_llvm_target_triple(self)
228+
localtarget_triple=_get_llvm_target_triple(toolchain)
229229
localarch=target_tripleandtarget_triple:split("-")[1]
230230

231+
localplat
232+
iftoolchain:is_plat("windows")then
233+
plat="windows"
234+
elseiftoolchain:is_plat("linux")then
235+
plat="linux"
236+
elseiftoolchain:is_plat("macosx","ios","watchos","appletvos","applexros")then
237+
plat="darwin"
238+
end
239+
240+
231241
localtripletdir=target_tripleandpath.join(res_libdir,"windows",target_triple)
232242
tripletdir=os.isdir(tripletdir)ornil
233243

234-
localrtdir=tripletdirandpath.join("windows",target_triple)or"windows"
235-
ifos.isdir(path.join(res_libdir,rtdir))then
244+
localrtdir=tripletdirandpath.join(plat,target_triple)orplat
245+
ifos.isdir(path.join(res_libdir,rtdir))andtoolchain:is_plat("windows")then
236246
localrtlink="clang_rt.builtins".. (tripletdirand".lib"or ("-"..arch..".lib"))
237247
ifos.isfile(path.join(res_libdir,rtdir,rtlink))then
238-
returnres_libdir,path.join(rtdir,rtlink)
248+
returnres_libdir,path.join(rtdir,rtlink),path.join(res_libdir,rtdir)
239249
end
240250
end
241-
returnres_libdir
251+
returnres_libdir,nil,path.join(res_libdir,rtdir)
242252
end
243253
end
244254
end
245255

246256
-- get llvm target triple
247-
function_get_llvm_target_triple(self)
257+
function_get_llvm_target_triple(toolchain)
248258
localllvm_targettriple=_g._LLVM_TARGETTRIPLE
249259
ifllvm_targettriple==nilthen
250-
localoutdata=try {function()returnos.iorunv(self:program(), {"-print-target-triple"}, {envs=self:runenvs()})end }
260+
localoutdata=try {function()returnos.iorunv(toolchain:tool("cc"), {"-print-target-triple"}, {envs=toolchain:runenvs()})end }
251261
ifoutdatathen
252262
llvm_targettriple=outdata:trim()
253263
end
@@ -257,49 +267,40 @@ function _get_llvm_target_triple(self)
257267
end
258268

259269
-- get llvm toolchain dirs
260-
functionget_llvm_dirs(toolchain)
270+
functionget_llvm_dirs(toolchain,rootdir)
261271
localllvm_dirs=_g.llvm_dirs
262272
ifllvm_dirs==nilthen
263-
localrootdir=toolchain:sdkdir()
264273
ifnotrootdirandtoolchain:is_plat("windows")then
265274
rootdir=_get_llvm_rootdir(toolchain)
266275
end
267276

268277
localbindir,libdir,cxxlibdir,includedir,cxxincludedir,resdir,rtdir,rtlink
269278
ifrootdirthen
270279
bindir=path.join(rootdir,"bin")
271-
ifbindirthen
272-
bindir=os.isdir(bindir)andbindirornil
273-
end
280+
bindir=os.isdir(bindir)andbindirornil
274281

275282
libdir=path.join(rootdir,"lib")
276-
iflibdirthen
277-
libdir=os.isdir(libdir)andlibdirornil
278-
end
283+
libdir=os.isdir(libdir)andlibdirornil
279284

280285
iflibdirthen
281-
cxxlibdir=libdirandpath.join(libdir,"c++")
282-
ifcxxlibdirthen
286+
cxxlibdir=path.join(libdir,"c++")
287+
cxxlibdir=os.isdir(cxxlibdir)andcxxlibdirornil
288+
ifnotcxxlibdirthen
289+
cxxlibdir=path.join(libdir,_get_llvm_target_triple(toolchain))
283290
cxxlibdir=os.isdir(cxxlibdir)andcxxlibdirornil
284291
end
285292
end
286293

287294
includedir=path.join(rootdir,"include")
288-
ifincludedirthen
289-
includedir=os.isdir(includedir)andincludedirornil
290-
end
295+
includedir=os.isdir(includedir)andincludedirornil
291296

292297
ifincludedirthen
293-
cxxincludedir=includedirandpath.join(includedir,"c++","v1")ornil
294-
ifcxxincludedirthen
295-
cxxincludedir=os.isdir(cxxincludedir)andcxxincludedirornil
296-
end
298+
cxxincludedir=path.join(includedir,"c++","v1")
299+
cxxincludedir=os.isdir(cxxincludedir)andcxxincludedirornil
297300
end
298301

299302
resdir=_get_llvm_resourcedir(toolchain)
300-
iftoolchain:is_plat("windows")then
301-
rtdir,rtlink=_get_llvm_compiler_win_rtdir_and_link(toolchain)
302-
end
303+
rtdir,rtlink,rtlib=_get_llvm_compiler_rtdir_and_link(toolchain)
303304
end
304305

305306
llvm_dirs= {root=rootdir,
@@ -310,6 +311,7 @@ function get_llvm_dirs(toolchain)
310311
cxxinclude=cxxincludedir,
311312
res=resdir,
312313
rt=rtdir,
314+
rtlib=rtlib,
313315
rtlink=rtlink }
314316
_g.llvm_dirs=llvm_dirs
315317
end

‎xmake/toolchains/clang/load.lua‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import("detect.sdks.find_vstudio")
2222
import("detect.sdks.find_mingw")
2323
import("core.project.config")
24+
import("private.utils.toolchain", {alias="toolchain_utils"})
2425

2526
-- add the given vs environment
2627
function_add_vsenv(toolchain,name,curenvs)
@@ -66,6 +67,22 @@ function main(toolchain, suffix)
6667
target="armv7"
6768
end
6869

70+
localdirs=toolchain_utils.get_llvm_dirs(toolchain,toolchain:sdkdir())
71+
ifdirsthen
72+
ifdirs.binthen
73+
toolchain:add("runenvs",dirs.bin)
74+
end
75+
ifdirs.libthen
76+
toolchain:add("runenvs",dirs.lib)
77+
end
78+
ifdirs.cxxlibthen
79+
toolchain:add("runenvs",dirs.cxxlib)
80+
end
81+
ifdirs.rtlibthen
82+
toolchain:add("runenvs",dirs.rtlib)
83+
end
84+
end
85+
6986
iftoolchain:is_plat("windows")then
7087
target=target.."-windows-msvc"
7188

‎xmake/toolchains/llvm/xmake.lua‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,20 @@ toolchain("llvm")
5454
toolchain:add("runtimes","MT","MTd","MD","MDd")
5555
end
5656

57-
localdirs=toolchain_utils.get_llvm_dirs(toolchain)
58-
ifdirsanddirs.rtthen
59-
toolchain:add("runenvs",dirs.rt)
57+
localdirs=toolchain_utils.get_llvm_dirs(toolchain,toolchain:sdkdir())
58+
ifdirsthen
59+
ifdirs.binthen
60+
toolchain:add("runenvs",dirs.bin)
61+
end
62+
ifdirs.libthen
63+
toolchain:add("runenvs",dirs.lib)
64+
end
65+
ifdirs.cxxlibthen
66+
toolchain:add("runenvs",dirs.cxxlib)
67+
end
68+
ifdirs.rtlibthen
69+
toolchain:add("runenvs",dirs.rtlib)
70+
end
6071
end
6172

6273
-- add target flags

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp