summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-24 22:34:36 +0800
committerruki <[email protected]>2024-01-25 12:09:59 +0800
commit3b3b6c0c1b3bec273a4af6052ec98e17bbc8ac39 (patch)
tree00a559ceae15c6f2a82accb5795f71f1bc87f080
parent7c0fcf37dae8da15fe47f5ae8c35bcfa07570e0a (diff)
check static libstdc++
-rw-r--r--xmake/modules/core/tools/clang.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 673500599..a34487686 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -178,6 +178,20 @@ function _has_ms_runtime_lib(self)
return has_ms_runtime_lib
end
+-- has -static-libstdc++?
+function _has_static_libstdcxx(self)
+ local has_static_libstdcxx = _g._HAS_STATIC_LIBSTDCXX
+ if has_static_libstdcxx == nil then
+ if self:has_flags("-static-libstdc++ -Werror", "ldflags", {flagskey = "clang_static_libstdcxx"}) then
+ has_static_libstdcxx = true
+ end
+ has_static_libstdcxx = has_static_libstdcxx or false
+ _g._HAS_STATIC_LIBSTDCXX = has_static_libstdcxx
+ end
+ return has_static_libstdcxx
+end
+
+
-- make the runtime flag
-- @see https://github.com/xmake-io/xmake/issues/3546
function nf_runtime(self, runtime)
@@ -217,11 +231,15 @@ function nf_runtime(self, runtime)
}
else
maps = {
- ["c++_static"] = {"-stdlib=libc++", "-static-libstdc++"},
+ ["c++_static"] = "-stdlib=libc++",
["c++_shared"] = "-stdlib=libc++",
- ["stdc++_static"] = {"-stdlib=libstdc++", "-static-libstdc++"},
+ ["stdc++_static"] = "-stdlib=libstdc++",
["stdc++_shared"] = "-stdlib=libstdc++",
}
+ if runtime:endswith("_static") and _has_static_libstdcxx(self) then
+ maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++")
+ maps["stdc++_static"] = table.join(maps["stdc++_static"], "-static-libstdc++")
+ end
end
return maps and maps[runtime]
end