Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add stdc++_static for gcc #4869

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions xmake/modules/core/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 2 additions & 11 deletions xmake/toolchains/mingw/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down