diff options
| author | ruki <[email protected]> | 2024-03-22 23:58:30 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-22 23:58:30 +0800 |
| commit | 6c78298c58fd710a28a42ea4ad77d34a41d5a655 (patch) | |
| tree | 8678b5d25fa6b47c068d97ee7147cbb9945d68be | |
| parent | fe6ad08f154298b105f82464f8d1c2d5a35241cc (diff) | |
| parent | efb782bbea442127e806df945f3f3ad81a40ae3f (diff) | |
Merge pull request #4869 from xmake-io/mingw
add stdc++_static for gcc
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 32 | ||||
| -rw-r--r-- | xmake/toolchains/mingw/xmake.lua | 13 |
2 files changed, 34 insertions, 11 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index e4e658749..216898f97 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -185,6 +185,38 @@ function nf_vectorext(self, extension) return maps[extension] 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 = "gcc_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 +function nf_runtime(self, runtime, opt) + opt = opt or {} + local maps + local kind = self:kind() + if not self:is_plat("android") then -- we will set runtimes in android ndk toolchain + maps = maps or {} + if kind == "ld" or kind == "sh" then + local target = opt.target + if target and target.sourcekinds and table.contains(table.wrap(target:sourcekinds()), "cxx") then + if runtime:endswith("_static") and _has_static_libstdcxx(self) then + maps["stdc++_static"] = "-static-libstdc++" + end + end + end + end + return maps and maps[runtime] +end + -- make the language flag function nf_language(self, stdname) diff --git a/xmake/toolchains/mingw/xmake.lua b/xmake/toolchains/mingw/xmake.lua index b2d5977fd..03b149bd4 100644 --- a/xmake/toolchains/mingw/xmake.lua +++ b/xmake/toolchains/mingw/xmake.lua @@ -18,23 +18,14 @@ -- @file xmake.lua -- --- define toolchain toolchain("mingw") - - -- set homepage + set_kind("standalone") set_homepage("http://www.mingw.org/") set_description("Minimalist GNU for Windows") + set_runtimes("stdc++_static", "stdc++_shared") - -- mark as standalone toolchain - set_kind("standalone") - - -- check toolchain on_check("check") - - -- on load on_load(function (toolchain) - - -- imports import("core.project.config") -- get cross |
