summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-18 22:56:48 +0800
committerruki <[email protected]>2025-12-18 22:56:48 +0800
commitb1e1b3e8017e37d0db6983a8a69be87d3e419002 (patch)
tree606da2e99ca28e555acf51406b95cf0bb2f12571
parent0b8c8bf80392e56710ef760b2604fd29a185556c (diff)
add llvm rtlib
-rw-r--r--xmake/modules/private/utils/toolchain.lua13
-rw-r--r--xmake/toolchains/llvm/xmake.lua1
2 files changed, 12 insertions, 2 deletions
diff --git a/xmake/modules/private/utils/toolchain.lua b/xmake/modules/private/utils/toolchain.lua
index f742cf295..d687adf09 100644
--- a/xmake/modules/private/utils/toolchain.lua
+++ b/xmake/modules/private/utils/toolchain.lua
@@ -281,7 +281,7 @@ function get_llvm_dirs(toolchain)
rootdir = _get_llvm_rootdir(toolchain)
end
- local bindir, libdir, cxxlibdir, includedir, cxxincludedir, resdir, rtdir, rtlink
+ local bindir, libdir, cxxlibdir, includedir, cxxincludedir, resdir, rtdir, rtlink, rtlib
if rootdir then
bindir = path.join(rootdir, "bin")
bindir = os.isdir(bindir) and bindir or nil
@@ -321,7 +321,6 @@ function get_llvm_dirs(toolchain)
rtlib = rtlib,
rtlink = rtlink }
memcache:set(cachekey, llvm_dirs)
- _g.llvm_dirs = llvm_dirs
end
return llvm_dirs
end
@@ -350,3 +349,13 @@ function set_llvm_runenvs(toolchain)
end
end
end
+
+-- add compiler-rt for llvm
+function add_llvm_compiler_rt(toolchain)
+ local dirs = get_llvm_dirs(toolchain)
+ if dirs and dirs.rtlib and dirs.rtlink then
+ local rtlib_path = path.join(dirs.rtlib, path.filename(dirs.rtlink))
+ toolchain:add("ldflags", rtlib_path)
+ toolchain:add("shflags", rtlib_path)
+ end
+end
diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua
index 7de57be22..0c660a13a 100644
--- a/xmake/toolchains/llvm/xmake.lua
+++ b/xmake/toolchains/llvm/xmake.lua
@@ -58,6 +58,7 @@ toolchain("llvm")
end
toolchain_utils.set_llvm_runenvs(toolchain)
+ toolchain_utils.add_llvm_compiler_rt(toolchain)
-- add target flags
local target