Skip to content

Commit 0132587

Browse files
committed
(C++ modules support) fix clang-cl (disable build.c++.modules.two_phases)
1 parent 42ba909 commit 0132587

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
inherit(".test_base")
2+
3+
function main(_)
4+
-- clang-cl doesn't support mixing pch and C++ module atm
5+
local clang_options = {compiler = "clang", version = CLANG_MIN_VER, disable_clang_cl = true}
6+
local gcc_options = {compiler = "gcc", version = GCC_MIN_VER}
7+
local msvc_options = {version = MSVC_MIN_VER}
8+
run_tests(clang_options, gcc_options, msvc_options)
9+
end

tests/projects/c++/modules/test_base.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import("core.tool.toolchain")
44
import("utils.ci.is_running", {alias = "ci_is_running"})
55

66
CLANG_MIN_VER = "17"
7+
CLANG_CL_MIN_VER = "19"
78
GCC_MIN_VER = "11"
89
MSVC_MIN_VER = "14.29"
910

@@ -127,9 +128,12 @@ function run_tests(clang_options, gcc_options, msvc_options)
127128
if clang_options then
128129
build_tests("llvm", clang_options)
129130
build_tests("clang", clang_options)
130-
local clang_cl_options = table.clone(clang_options)
131-
clang_cl_options.compiler = "clang-cl"
132-
build_tests("clang-cl", clang_cl_options)
131+
if not clang_options.disable_clang_cl then
132+
local clang_cl_options = table.clone(clang_options)
133+
clang_cl_options.compiler = "clang-cl"
134+
clang_cl_options.version = CLANG_CL_MIN_VER
135+
build_tests("clang-cl", clang_cl_options)
136+
end
133137
if not clang_options.stdmodule then
134138
build_tests("llvm", clang_libcpp_options)
135139
build_tests("clang", clang_libcpp_options)

xmake/rules/c++/modules/clang/builder.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ function _get_requiresflags(target, module)
182182
end
183183
end
184184
requiresflags = table.unique(requiresflags)
185-
-- table.sort(requiresflags)
186185
support.memcache():set2(cachekey, "requiresflags", requiresflags)
187186
support.memcache():set2(cachekey, "oldrequires", requires)
188187
end

xmake/rules/c++/modules/config.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ function main(target)
6767
wprint("build.c++.modules.tryreuse.discriminate_on_defines is deprecated, please use build.c++.modules.reuse.strict")
6868
end
6969

70+
if target:has_tool("cxx", "clang_cl") then
71+
target:set("policy", "build.c++.modules.two_phases", false)
72+
end
73+
7074
-- if containes modules, enable objectfiles output of c++.build.modules.builder
7175
local rule = target:rule("c++.build.modules.builder")
7276
rule = rule:clone()

xmake/rules/c++/modules/scanner.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,12 @@ function _patch_sourcebatch(target, sourcebatch)
389389

390390
local can_reuse = nocheck or _are_flags_compatible(target, dep, sourcefile, {strict = strict})
391391
if can_reuse then
392-
support.set_reused(target, dep, sourcefile)
392+
local _reused, from = support.is_reused(dep, sourcefile)
393+
if _reused then
394+
support.set_reused(target, from, sourcefile)
395+
else
396+
support.set_reused(target, dep, sourcefile)
397+
end
393398
table.insert(reused, sourcefile)
394399
if dep:is_moduleonly() then
395400
dep:data_set("cxx.modules.reused", true)
@@ -417,10 +422,15 @@ function _patch_sourcebatch(target, sourcebatch)
417422
if reused:has(sourcefile) then
418423
local dep = target:dep(fileconfig.external)
419424
assert(dep, "dep target <%s> for <%s> not found", fileconfig.external, target:fullname())
425+
local _reused, from = support.is_reused(dep, sourcefile)
426+
if _reused then
427+
support.set_reused(target, from, sourcefile)
428+
else
429+
support.set_reused(target, dep, sourcefile)
430+
end
420431
if dep:is_moduleonly() then
421432
dep:data_set("cxx.modules.reused", true)
422433
end
423-
support.set_reused(target, dep, sourcefile)
424434
end
425435
target:fileconfig_add(sourcefile, fileconfig)
426436
end

0 commit comments

Comments
 (0)