summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/clang/builder.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-09-10 21:37:49 +0200
committerArthur LAURENT <[email protected]>2025-09-10 21:37:49 +0200
commit750f981b289ffc6fff43a342be73623bc23eba22 (patch)
treef007b13f7107b16540c8311d341bcefc4de051be /xmake/rules/c++/modules/clang/builder.lua
parentb8f8ebe2e6489c1994140d6cfff8ac31c8333264 (diff)
nfc(C++ modules) optimize two phases build for clang by using pcm file to compile objectfile instead of module sourcefile
Diffstat (limited to 'xmake/rules/c++/modules/clang/builder.lua')
-rw-r--r--xmake/rules/c++/modules/clang/builder.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/xmake/rules/c++/modules/clang/builder.lua b/xmake/rules/c++/modules/clang/builder.lua
index a43c8aebe..042148910 100644
--- a/xmake/rules/c++/modules/clang/builder.lua
+++ b/xmake/rules/c++/modules/clang/builder.lua
@@ -34,6 +34,7 @@ import(".builder", {inherit = true})
function _make_modulebuildflags(target, module, opt)
assert(not module.headerunit)
local flags
+ local two_phases = target:policy("build.c++.modules.two_phases")
if opt.bmi then
local module_outputflag = support.get_moduleoutputflag(target)
@@ -50,7 +51,10 @@ function _make_modulebuildflags(target, module, opt)
end
table.insert(flags, module_outputflag .. module.bmifile)
else
- flags = {"-x", "c++"}
+ flags = {}
+ if not two_phases or not module.bmifile then
+ flags = {"-x", "c++"}
+ end
local std = (module.name == "std" or module.name == "std.compat")
if std then
table.join2(flags, {"-Wno-include-angled-in-module-purview", "-Wno-reserved-module-identifier", "-Wno-deprecated-declarations"})
@@ -127,10 +131,13 @@ function _compile(target, flags, module, opt)
opt = opt or {}
local sourcefile = module.sourcefile
+ if not opt.bmi and opt.objectfile and module.bmifile then
+ sourcefile = module.bmifile
+ end
local outputfile = ((opt.bmi and not opt.objectfile) or opt.headerunit) and module.bmifile or module.objectfile
local dryrun = option.get("dry-run")
local compinst = target:compiler("cxx")
- local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
+ local compflags = compinst:compflags({sourcefile = module.sourcefile, target = target, sourcekind = "cxx"})
flags = table.join(compflags or {}, flags or {})
-- trace
local cmd
@@ -152,7 +159,7 @@ function _batchcmds_compile(batchcmds, target, flags, module, opt)
local sourcefile = module.sourcefile
local outputfile = (opt.bmi and not opt.objectfile) and module.bmifile or module.objectfile
local compinst = target:compiler("cxx")
- local compflags = compinst:compflags({sourcefile = sourcefile, target = target, sourcekind = "cxx"})
+ local compflags = compinst:compflags({sourcefile = module.sourcefile, target = target, sourcekind = "cxx"})
flags = table.join("-c", compflags or {}, flags or {}, {"-o", outputfile, sourcefile})
-- trace