Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-gcc-link-module-order' into …
Browse files Browse the repository at this point in the history
…fix-module-link-order
  • Loading branch information
Arthapz committed Dec 7, 2022
2 parents 425e4b9 + b0f3257 commit e33abe5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/projects/c++/modules/link_order/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ target("link_order_1")
target("link_order_2")
set_kind("binary")
add_deps("bar", "foo")
add_files("src/main.cpp")
add_files("src/main.cpp")
8 changes: 4 additions & 4 deletions xmake/rules/c++/modules/modules_support/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ end
-- load module support for the current target
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 .. path(_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")
end
Expand Down Expand Up @@ -108,7 +106,8 @@ function _build_modulefile(target, sourcefile, opt)
local objectfile = opt.objectfile
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = table.join("-x", "c++", compinst:compflags({target = target}))
local modulemapperflag = get_modulemapperflag(target)
local compflags = table.join("-x", "c++", modulemapperflag .. path.translate(_get_module_mapper(target)), compinst:compflags({target = target}))
local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})

-- need build this object?
Expand Down Expand Up @@ -456,6 +455,7 @@ end
-- build module files for batchcmds
function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, opt)
local compinst = target:compiler("cxx")
local modulemapperflag = get_modulemapperflag(target)
local mapper_file = _get_module_mapper(target)

-- build modules
Expand Down Expand Up @@ -493,7 +493,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op
break
end
end
local flags = {"-x", "c++","-c", path(cppfile), "-o", path(objectfile)}
local flags = {"-x", "c++", modulemapperflag .. path.translate(_get_module_mapper(target)),"-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 e33abe5

Please sign in to comment.