summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/clang.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-22 22:33:01 +0800
committerruki <[email protected]>2024-01-25 12:09:58 +0800
commit5d2f15a1004be7baaaeb08b2e196ad77c52f9647 (patch)
tree95e24fb92cf22cbbf20deb66b5a5cf68b8686ed4 /xmake/modules/core/tools/clang.lua
parentbda43e3e865e2336db2bdf2b66af9beb235da1df (diff)
improve clang runtime
Diffstat (limited to 'xmake/modules/core/tools/clang.lua')
-rw-r--r--xmake/modules/core/tools/clang.lua32
1 files changed, 25 insertions, 7 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 28a00d84f..c9c6b854d 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -178,18 +178,18 @@ function _has_ms_runtime_lib(self)
return has_ms_runtime_lib
end
--- make vs runtime flag
+-- make the runtime flag
-- @see https://github.com/xmake-io/xmake/issues/3546
-function nf_runtime(self, vs_runtime)
- if self:is_plat("windows") and vs_runtime then
+function nf_runtime(self, runtime)
+ local kind = self:kind()
+ if self:is_plat("windows") and runtime then
if not _has_ms_runtime_lib(self) then
- if vs_runtime:startswith("MD") then
- wprint("%s runtime is not available for the current Clang compiler.", vs_runtime)
+ if runtime:startswith("MD") then
+ wprint("%s runtime is not available for the current Clang compiler.", runtime)
end
return
end
local maps
- local kind = self:kind()
if language.sourcekinds()[kind] then
maps = {
MT = "-fms-runtime-lib=static",
@@ -205,7 +205,25 @@ function nf_runtime(self, vs_runtime)
MDd = "-nostdlib"
}
end
- return maps and maps[vs_runtime]
+ return maps and maps[runtime]
+ else
+ local maps
+ if kind == "cxx" then
+ maps = {
+ ["c++_static"] = "-stdlib=libc++",
+ ["c++_shared"] = "-stdlib=libc++",
+ ["stdc++_static"] = "-stdlib=libstdc++",
+ ["stdc++_shared"] = "-stdlib=libstdc++",
+ }
+ else
+ maps = {
+ ["c++_static"] = {"-stdlib=libc++", "-static-libstdc++"},
+ ["c++_shared"] = "-stdlib=libc++",
+ ["stdc++_static"] = {"-stdlib=libstdc++", "-static-libstdc++"},
+ ["stdc++_shared"] = "-stdlib=libstdc++",
+ }
+ end
+ return maps and maps[runtime]
end
end