summaryrefslogtreecommitdiff
path: root/xmake/toolchains
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-23 22:42:38 +0800
committerruki <[email protected]>2025-12-23 22:42:38 +0800
commite0c5f68ea4892333ca4a4b10362f1e9aa8ce9118 (patch)
treed1e0749124dc6d1108e550a36640655ebff58ed0 /xmake/toolchains
parentf5adbc00fad0f91ccb820856a859a5223d9080e9 (diff)
improve llvm/clang toolchain
Diffstat (limited to 'xmake/toolchains')
-rw-r--r--xmake/toolchains/clang-cl/load.lua10
-rw-r--r--xmake/toolchains/clang/load.lua20
2 files changed, 21 insertions, 9 deletions
diff --git a/xmake/toolchains/clang-cl/load.lua b/xmake/toolchains/clang-cl/load.lua
index f69b98cb3..e06883012 100644
--- a/xmake/toolchains/clang-cl/load.lua
+++ b/xmake/toolchains/clang-cl/load.lua
@@ -47,11 +47,15 @@ function main(toolchain)
toolchain:set("toolset", "ar", "link.exe")
end
+ -- add llvm runenvs before adding vsenvs
+ --
+ -- The dynamic libraries (DLLs) for Clang ASan and MSVC ASan share the same filename, making them incompatible.
+ -- Currently, runenvs maybe have Visual Studio environment variables.
+ -- If the Clang path is not prioritized (placed first), the system incorrectly loads the MSVC ASan DLL, resulting in a runtime failure.
+ toolchain_utils.add_llvm_runenvs(toolchain)
+
-- add vs environments
toolchain_utils.add_vsenvs(toolchain)
-
- -- add llvm runenvs
- toolchain_utils.add_llvm_runenvs(toolchain)
-- add target flags
local flags = toolchain_utils.get_clang_target_flags(toolchain)
diff --git a/xmake/toolchains/clang/load.lua b/xmake/toolchains/clang/load.lua
index 14bffea51..4a12b31ce 100644
--- a/xmake/toolchains/clang/load.lua
+++ b/xmake/toolchains/clang/load.lua
@@ -52,14 +52,22 @@ function main(toolchain, suffix)
toolchain:add("shflags", flags)
end
- -- init windows
- if toolchain:is_plat("windows") then
- _load_windows(toolchain, suffix)
- end
-
-- set llvm runtimes
toolchain_utils.set_llvm_runtimes(toolchain)
- -- add llvm runenvs
+ -- add llvm runenvs before adding vsenvs
+ --
+ -- The dynamic libraries (DLLs) for Clang ASan and MSVC ASan share the same filename, making them incompatible.
+ -- Currently, runenvs maybe have Visual Studio environment variables.
+ -- If the Clang path is not prioritized (placed first), the system incorrectly loads the MSVC ASan DLL, resulting in a runtime failure.
toolchain_utils.add_llvm_runenvs(toolchain)
+
+ -- add configs for windows
+ if toolchain:is_plat("windows") then
+ toolchain_utils.add_vsenvs(toolchain)
+ if is_host("linux") or project.policy("build.optimization.lto") then
+ toolchain:add("ldflags", "-fuse-ld=lld-link" .. suffix)
+ toolchain:add("shflags", "-fuse-ld=lld-link" .. suffix)
+ end
+ end
end