summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-05-15 23:35:16 +0800
committerruki <[email protected]>2025-05-15 23:35:16 +0800
commit8fe7c166f84ee0460c79a63f5dc19d4ca77dade1 (patch)
tree1bb7372dfbd7ec92f6f85b7cebb76d14d0719c06
parenta68eff4a47e81b8ea430ee4f4a86d1fd8ccc7df9 (diff)
fix link objectfiles conflicts
-rw-r--r--xmake/core/project/target.lua15
-rw-r--r--xmake/rules/c++/modules/support.lua2
-rw-r--r--xmake/rules/c++/modules/xmake.lua19
3 files changed, 16 insertions, 20 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 974b0c9cc..475c06d19 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -2375,11 +2375,16 @@ function _instance:sourcebatches()
sourcebatch.sourcekind = sourcekind
-- insert object files to source batches
- sourcebatch.objectfiles = sourcebatch.objectfiles or {}
- sourcebatch.dependfiles = sourcebatch.dependfiles or {}
- local objectfile = self:objectfile(sourcefile, sourcekind)
- table.insert(sourcebatch.objectfiles, objectfile)
- table.insert(sourcebatch.dependfiles, self:dependfile(objectfile))
+ -- and we need to avoid duplication with object files, which may cause some conflicts.
+ -- e.g. c++.build, c++ module and unity_build rules
+ -- @see https://github.com/xmake-io/xmake/issues/6420
+ if filerule:extraconf("sourcekinds", sourcekind, "objectfiles") ~= false then
+ sourcebatch.objectfiles = sourcebatch.objectfiles or {}
+ sourcebatch.dependfiles = sourcebatch.dependfiles or {}
+ local objectfile = self:objectfile(sourcefile, sourcekind)
+ table.insert(sourcebatch.objectfiles, objectfile)
+ table.insert(sourcebatch.dependfiles, self:dependfile(objectfile))
+ end
end
end
end
diff --git a/xmake/rules/c++/modules/support.lua b/xmake/rules/c++/modules/support.lua
index 9353fae8a..faaa57369 100644
--- a/xmake/rules/c++/modules/support.lua
+++ b/xmake/rules/c++/modules/support.lua
@@ -158,7 +158,7 @@ function has_module_extension(sourcefile, opt)
opt = opt or {}
local modulexts = _g.modulexts
if modulexts == nil then
- modulexts = hashset.of(".mpp", ".mxx", ".cppm", ".ixx")
+ modulexts = hashset.of(".cppm", ".ccm", ".cxxm", ".c++m", ".mpp", ".mxx", ".ixx")
_g.modulexts = modulexts
end
local extension = opt.extension or path.extension(sourcefile)
diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua
index 64de8e017..9afd4f6cc 100644
--- a/xmake/rules/c++/modules/xmake.lua
+++ b/xmake/rules/c++/modules/xmake.lua
@@ -20,7 +20,6 @@
-- define rule: c++.build.modules
rule("c++.build.modules")
-
-- @note support.contains_modules() need it
set_extensions(".cppm", ".ccm", ".cxxm", ".c++m", ".mpp", ".mxx", ".ixx")
@@ -35,38 +34,30 @@ rule("c++.build.modules")
-- scan modules
rule("c++.build.modules.scanner")
- set_sourcekinds("cxx")
- set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
-
- -- generate module dependencies
+ set_sourcekinds("cxx", {objectfiles = false})
+ set_extensions(".cppm", ".ccm", ".cxxm", ".c++m", ".mpp", ".mxx", ".ixx")
on_prepare_files("scanner", {jobgraph = true})
-
- -- insert objectfiles
after_prepare_files("scanner.after_scan")
-- build modules
rule("c++.build.modules.builder")
- set_sourcekinds("cxx")
- set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
-
+ set_sourcekinds("cxx", {objectfiles = false})
+ set_extensions(".cppm", ".ccm", ".cxxm", ".c++m", ".mpp", ".mxx", ".ixx")
add_orders("c++.build.modules.scanner", "c++.build.modules.builder")
-- parallel build support to accelerate `xmake build` to build modules
before_build_files("builder.build_bmis", {jobgraph = true, batch = true})
-
on_build_files("builder.build_objectfiles", {jobgraph = true, batch = true})
-- serial compilation only, usually used to support project generator
before_buildcmd_files("builder.build_bmis")
-
on_buildcmd_files("builder.build_objectfiles")
after_clean("builder.clean")
-- install modules
rule("c++.build.modules.install")
- set_extensions(".mpp", ".mxx", ".cppm", ".ixx")
+ set_extensions(".cppm", ".ccm", ".cxxm", ".c++m", ".mpp", ".mxx", ".ixx")
before_install("install.install")
-
before_uninstall("install.uninstall")