summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/clang.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2023-02-15 18:15:06 +0100
committerArthur LAURENT <[email protected]>2023-02-15 18:15:16 +0100
commit475734e6f4a27a3e3f2cdab3d3a93a5e949b7b0e (patch)
tree41cec908488aee9b8a2dd6fdf943bcd7160ad629 /xmake/rules/c++/modules/modules_support/clang.lua
parent51fad68409dc0ac9c70702397d0d344ca0aaf3f9 (diff)
use -fmodule-file=<name>=<bmi> for named module on clang
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/clang.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 06425ff40..df3cd066b 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -79,15 +79,21 @@ end
-- -fmodule-file=build/.gens/Foo/rules/modules/cache/foo.pcm
-- -fmodule-file=build/.gens/Foo/rules/modules/cache/iostream.pcm
-- -fmodule-file=build/.gens/Foo/rules/modules/cache/bar.hpp.pcm
+-- on LLVM >= 16
+-- -fmodule-file=foo=build/.gens/Foo/rules/modules/cache/foo.pcm
+-- -fmodule-file=build/.gens/Foo/rules/modules/cache/iostream.pcm
+-- -fmodule-file=build/.gens/Foo/rules/modules/cache/bar.hpp.pcm
--
-function _add_module_to_mapper(target, name, bmifile, deps)
+function _add_module_to_mapper(target, name, bmifile, deps, namedmodule)
local modulemap = _get_modulemap_from_mapper(target, name)
if modulemap then
return
end
+ local clang_version = _get_clang_version(target)
+ namedmodule = namedmodule and semver.compare(clang_version, "16.0") >= 0
local modulefileflag = get_modulefileflag(target)
- local mapflag = modulefileflag .. bmifile
+ local mapflag = namedmodule and format("%s%s=%s", modulefileflag, name, bmifile) or modulefileflag .. bmifile
modulemap = {flag = mapflag, deps = deps}
common.localcache():set2(_mapper_cachekey(target), "modulemap" .. name, modulemap)
end
@@ -596,7 +602,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
target:add("objectfiles", objectfile)
if provide then
- _add_module_to_mapper(target, name, bmifile, requiresflags)
+ _add_module_to_mapper(target, name, bmifile, requiresflags, true)
end
elseif requiresflags then
local cxxflags = {}
@@ -658,7 +664,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op
if provide then
_batchcmds_compile(batchcmds, target, table.join(flags,
{"-x", "c++-module", "--precompile", "-c", path(cppfile), "-o", path(provide.bmi)}))
- _add_module_to_mapper(target, name, provide.bmi)
+ _add_module_to_mapper(target, name, provide.bmi, nil, true)
end
_batchcmds_compile(batchcmds, target, file, table.join(flags,
not provide and {"-x", "c++"} or {}, {"-c", file, "-o", path(objectfile)}))