Skip to content

Commit

Permalink
fix gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthapz committed Dec 7, 2022
1 parent 36b8476 commit efdbbaa
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions xmake/rules/c++/modules/modules_support/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,12 @@ end
function load(target)
local modulesflag = get_modulesflag(target)
local modulemapperflag = get_modulemapperflag(target)
target:add("cxxflags", modulesflag)
if os.isfile(_get_module_mapper(target)) then
os.rm(_get_module_mapper(target))
end
target:add("cxxflags", modulemapperflag .. _get_module_mapper(target), {force = true, expand = false})
target:add("cxxflags", {modulesflag, modulemapperflag .. path.translate(_get_module_mapper(target))}, {force = true, expand = false})
-- fix cxxabi issue, @see https://github.com/xmake-io/xmake/issues/2716#issuecomment-1225057760
target:add("cxxflags", "-D_GLIBCXX_USE_CXX11_ABI=0")
local deps_mappers
for _, dep in ipairs(target:orderdeps()) do
deps_mappers = deps_mappers or {}
table.insert(deps_mappers, 1, modulemapperflag .. _get_module_mapper(dep))
end
if deps_mappers then
target:add("cxxflags", deps_mappers, {force = true, expand = false})
end
end

-- get includedirs for stl headers
Expand Down Expand Up @@ -487,7 +478,21 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op
break
end
end
local flags = {"-x", "c++","-c", path(cppfile), "-o", path(objectfile)}
-- append dependencies module now to ensures deps modulemap is filled
for required, _ in pairs(module.requires) do
local m
for _, dep in ipairs(target:orderdeps()) do
m = _get_module_from_mapper(_get_module_mapper(dep), required)
if m then
break
end
end
if m then
_add_module_to_mapper(mapper_file, m[1], m[2])
break
end
end
local flags = {"-x", "c++", "-c", path(cppfile), "-o", path(objectfile)}
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.module.$(mode) %s", name or cppfile)
batchcmds:mkdir(path.directory(objectfile))
batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), flags))
Expand Down

0 comments on commit efdbbaa

Please sign in to comment.