From 13ae811418d4855cb5cc223d7e4546771f704e6f Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 4 Jan 2023 22:30:23 +0100 Subject: Improve compatibility with libc++ --- tests/projects/c++/modules/test_base.lua | 3 +++ tests/projects/c++/modules/test_headerunits.lua | 3 +++ xmake/rules/c++/modules/modules_support/clang.lua | 29 ++++++++++++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 4aee9f8e7..580110cb6 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -25,6 +25,9 @@ function main(t) os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang -c") _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + _build() end end end diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 905812c14..85c6c35b3 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -29,6 +29,9 @@ function main(t) os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang -c") _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + _build() end end end diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 02d08e6b0..d73b17533 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -67,13 +67,12 @@ end -- load module support for the current target function load(target) local modulesflag = get_modulesflag(target) - local builtinmodulemapflag = get_builtinmodulemapflag(target) - local implicitmodulesflag = get_implicitmodulesflag(target) + local noimplicitmodulemapsflag = get_noimplicitmodulemapsflag(target) -- add module flags target:add("cxxflags", modulesflag) - target:add("cxxflags", builtinmodulemapflag, {force = true}) - target:add("cxxflags", implicitmodulesflag, {force = true}) + -- target:add("cxxflags", builtinmodulemapflag, {force = true}) + target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file -- module.pcm cannot be loaded due to a configuration mismatch with the current compilation. @@ -97,7 +96,8 @@ function load(target) -- on ubuntu: -- sudo apt install libc++-dev libc++abi-15-dev -- - target:data_set("cxx.modules.use_libc++", table.contains(target:get("cxxflags"), "-stdlib=libc++", "clang::-stdlib=libc++")) + local flags = table.join(target:get("cxxflags"), get_config("cxxflags") or {}) + target:data_set("cxx.modules.use_libc++", table.contains(flags, "-stdlib=libc++", "clang::-stdlib=libc++")) if target:data("cxx.modules.use_libc++") then target:add("syslinks", "c++") end @@ -117,7 +117,7 @@ function _get_toolchain_includedirs_for_stlheaders(target, includedirs, clang) if target:data("cxx.modules.use_libc++") then table.insert(argv, 1, "-stdlib=libc++") end - local result = try {function () return os.iorunv(clang, {"-E", "-x", "c++", tmpfile}) end} + local result = try {function () return os.iorunv(clang, argv) end} if result then for _, line in ipairs(result:split("\n", {plain = true})) do line = line:trim() @@ -199,7 +199,7 @@ function toolchain_includedirs(target) local clang, toolname = target:tool("cxx") assert(toolname == "clang") _get_toolchain_includedirs_for_stlheaders(target, includedirs, clang) - local _, result = try {function () return os.iorunv(clang, {"-E", "-Wp,-v", "-xc", os.nuldev()}) end} + local _, result = try {function () return os.iorunv(clang, {"-E", "-stdlib=libc++", "-Wp,-v", "-xc", os.nuldev()}) end} if result then for _, line in ipairs(result:split("\n", {plain = true})) do line = line:trim() @@ -292,7 +292,7 @@ function generate_stl_headerunits_for_batchjobs(target, batchjobs, headerunits, if not common.memcache():get2(headerunit.name, "building") then common.memcache():set2(headerunit.name, "building", true) progress.show((index * 100) / total, "${color.build.object}compiling.headerunit.$(mode) %s", headerunit.name) - local args = {modulecachepathflag .. stlcachedir, "-c", "-o", bmifile, "-x", "c++-system-header", headerunit.name} + local args = {modulecachepathflag .. stlcachedir, "-c", "-Wno-everything", "-o", bmifile, "-x", "c++-system-header", headerunit.name} os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) end @@ -622,6 +622,19 @@ function get_implicitmodulesflag(target) return implicitmodulesflag or nil end +function get_implicitmodulemapsflag(target) + local implicitmodulemapsflag = _g.implicitmodulemapsflag + if implicitmodulemapsflag == nil then + local compinst = target:compiler("cxx") + if compinst:has_flags("-fimplicit-module-maps", "cxxflags", {flagskey = "clang_implicit_module_map"}) then + implicitmodulemapsflag = "-fimplicit-module-maps" + end + assert(implicitmodulemapsflag, "compiler(clang): does not support c++ module!") + _g.implicitmodulemapsflag = implicitmodulemapsflag or false + end + return implicitmodulemapsflag or nil +end + function get_noimplicitmodulemapsflag(target) local noimplicitmodulemapsflag = _g.noimplicitmodulemapsflag if noimplicitmodulemapsflag == nil then -- cgit v1.3.1 From ae744259de3d03a24b7a261251ebf0f4628fed87 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Fri, 6 Jan 2023 12:20:10 +0100 Subject: disable clang header units tests with -stdlib=libc++ --- tests/projects/c++/modules/test_headerunits.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 85c6c35b3..872defb35 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -29,9 +29,9 @@ function main(t) os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang -c") _build() - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") - _build() + -- os.exec("xmake clean -a") there is currently a bug on llvm git that prevent to build STL header units https://github.com/llvm/llvm-project/issues/58540 + -- os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + -- _build() end end end -- cgit v1.3.1 From 887d301d4117d9fcb36077441fa75fb704e322fc Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Fri, 6 Jan 2023 12:12:45 +0100 Subject: cleanup --- xmake/rules/c++/modules/modules_support/clang.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index d73b17533..9cf7edcdf 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -71,7 +71,6 @@ function load(target) -- add module flags target:add("cxxflags", modulesflag) - -- target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file -- cgit v1.3.1 From 3755a6f67399b8e42df9f39ec7c506918dbb433a Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sat, 7 Jan 2023 17:44:36 +0100 Subject: reenable old clang modules by default and fix tests --- tests/projects/c++/modules/class/xmake.lua | 4 ++ .../c++/modules/cpp_with_moduledeps/xmake.lua | 3 +- tests/projects/c++/modules/dependence/xmake.lua | 6 ++ tests/projects/c++/modules/dependence2/xmake.lua | 4 +- .../c++/modules/headerunits_person/xmake.lua | 6 +- .../c++/modules/hello with spaces/xmake.lua | 3 +- tests/projects/c++/modules/hello/xmake.lua | 1 + tests/projects/c++/modules/ifdef_module/xmake.lua | 1 + tests/projects/c++/modules/impl_unit/xmake.lua | 4 ++ .../c++/modules/inline_and_template/xmake.lua | 4 ++ .../c++/modules/internal_partition/xmake.lua | 1 + tests/projects/c++/modules/link_order/xmake.lua | 5 ++ tests/projects/c++/modules/partitions/test.lua | 2 +- tests/projects/c++/modules/partitions/xmake.lua | 6 +- tests/projects/c++/modules/partitions2/test.lua | 2 +- tests/projects/c++/modules/partitions2/xmake.lua | 6 +- .../projects/c++/modules/private_module/xmake.lua | 1 + tests/projects/c++/modules/staticlib/xmake.lua | 3 +- tests/projects/c++/modules/stdmodules/test.lua | 2 +- tests/projects/c++/modules/stdmodules/xmake.lua | 5 +- .../modules/stdmodules_multiple_targets/test.lua | 2 +- .../modules/stdmodules_multiple_targets/xmake.lua | 3 - .../projects/c++/modules/stl_headerunit/xmake.lua | 4 ++ .../c++/modules/stl_headerunit_cpp_only/xmake.lua | 75 ++-------------------- tests/projects/c++/modules/submodules/xmake.lua | 6 +- tests/projects/c++/modules/submodules2/xmake.lua | 4 +- tests/projects/c++/modules/test_base.lua | 10 +-- tests/projects/c++/modules/test_headerunits.lua | 11 ++-- tests/projects/c++/modules/test_msvc.lua | 28 -------- tests/projects/c++/modules/test_stdmodules.lua | 47 ++++++++++++++ .../projects/c++/modules/user_headerunit/xmake.lua | 2 + xmake/rules/c++/modules/modules_support/clang.lua | 10 ++- 32 files changed, 143 insertions(+), 128 deletions(-) delete mode 100644 tests/projects/c++/modules/test_msvc.lua create mode 100644 tests/projects/c++/modules/test_stdmodules.lua diff --git a/tests/projects/c++/modules/class/xmake.lua b/tests/projects/c++/modules/class/xmake.lua index 6d6eaddee..2dfca344c 100644 --- a/tests/projects/c++/modules/class/xmake.lua +++ b/tests/projects/c++/modules/class/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("class") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ diff --git a/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua b/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua index 5c7a8a6f7..6a9b3538f 100644 --- a/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua +++ b/tests/projects/c++/modules/cpp_with_moduledeps/xmake.lua @@ -1,10 +1,11 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") target("mod") set_kind("static") add_files("src/mod.mpp", "src/mod.cpp") -target("main") +target("cpp_with_moduledeps") set_kind("binary") add_deps("mod") add_files("src/main.cpp") diff --git a/tests/projects/c++/modules/dependence/xmake.lua b/tests/projects/c++/modules/dependence/xmake.lua index 6d64b49b1..b4ecdb1b9 100644 --- a/tests/projects/c++/modules/dependence/xmake.lua +++ b/tests/projects/c++/modules/dependence/xmake.lua @@ -1,4 +1,10 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("dependence") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + if has_config("libc++") then + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ + end \ No newline at end of file diff --git a/tests/projects/c++/modules/dependence2/xmake.lua b/tests/projects/c++/modules/dependence2/xmake.lua index 6d64b49b1..4f2905fe9 100644 --- a/tests/projects/c++/modules/dependence2/xmake.lua +++ b/tests/projects/c++/modules/dependence2/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("dependence") + +target("dependence2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/headerunits_person/xmake.lua b/tests/projects/c++/modules/headerunits_person/xmake.lua index c9290833b..93b635988 100644 --- a/tests/projects/c++/modules/headerunits_person/xmake.lua +++ b/tests/projects/c++/modules/headerunits_person/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("hello") + +target("headerunits_person") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it \ No newline at end of file diff --git a/tests/projects/c++/modules/hello with spaces/xmake.lua b/tests/projects/c++/modules/hello with spaces/xmake.lua index 4f46b699d..4369a892f 100644 --- a/tests/projects/c++/modules/hello with spaces/xmake.lua +++ b/tests/projects/c++/modules/hello with spaces/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") -target("A hello") + +target("hello with spaces") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/hello/xmake.lua b/tests/projects/c++/modules/hello/xmake.lua index de13fc409..4f6fdab98 100644 --- a/tests/projects/c++/modules/hello/xmake.lua +++ b/tests/projects/c++/modules/hello/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("hello") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/ifdef_module/xmake.lua b/tests/projects/c++/modules/ifdef_module/xmake.lua index ee931a801..25933a35f 100644 --- a/tests/projects/c++/modules/ifdef_module/xmake.lua +++ b/tests/projects/c++/modules/ifdef_module/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("ifdef_module") set_kind("binary") add_files("src/*.cpp") diff --git a/tests/projects/c++/modules/impl_unit/xmake.lua b/tests/projects/c++/modules/impl_unit/xmake.lua index abe41d20a..64db3cf8c 100644 --- a/tests/projects/c++/modules/impl_unit/xmake.lua +++ b/tests/projects/c++/modules/impl_unit/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("impl_unit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/inline_and_template/xmake.lua b/tests/projects/c++/modules/inline_and_template/xmake.lua index 4810edb85..57635eff3 100644 --- a/tests/projects/c++/modules/inline_and_template/xmake.lua +++ b/tests/projects/c++/modules/inline_and_template/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("inline_and_template") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/internal_partition/xmake.lua b/tests/projects/c++/modules/internal_partition/xmake.lua index f7ca6f7cf..422292295 100644 --- a/tests/projects/c++/modules/internal_partition/xmake.lua +++ b/tests/projects/c++/modules/internal_partition/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("internal_partition") set_kind("binary") add_files("src/*.cpp", "src/hello.mpp") diff --git a/tests/projects/c++/modules/link_order/xmake.lua b/tests/projects/c++/modules/link_order/xmake.lua index 6a11418ac..c6310055c 100644 --- a/tests/projects/c++/modules/link_order/xmake.lua +++ b/tests/projects/c++/modules/link_order/xmake.lua @@ -1,3 +1,8 @@ +option("libc++") + set_default(false) + set_showmenu(true) +option_end() + add_rules("mode.release", "mode.debug") set_languages("c++20") diff --git a/tests/projects/c++/modules/partitions/test.lua b/tests/projects/c++/modules/partitions/test.lua index c18e5a1d0..e77adc4ae 100644 --- a/tests/projects/c++/modules/partitions/test.lua +++ b/tests/projects/c++/modules/partitions/test.lua @@ -1 +1 @@ -inherit(".test_headerunits") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/partitions/xmake.lua b/tests/projects/c++/modules/partitions/xmake.lua index 672034947..68602dce4 100644 --- a/tests/projects/c++/modules/partitions/xmake.lua +++ b/tests/projects/c++/modules/partitions/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("partition") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/partitions2/test.lua b/tests/projects/c++/modules/partitions2/test.lua index c18e5a1d0..e77adc4ae 100644 --- a/tests/projects/c++/modules/partitions2/test.lua +++ b/tests/projects/c++/modules/partitions2/test.lua @@ -1 +1 @@ -inherit(".test_headerunits") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/partitions2/xmake.lua b/tests/projects/c++/modules/partitions2/xmake.lua index c9290833b..1dfd2321b 100644 --- a/tests/projects/c++/modules/partitions2/xmake.lua +++ b/tests/projects/c++/modules/partitions2/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("hello") + +target("partition2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ diff --git a/tests/projects/c++/modules/private_module/xmake.lua b/tests/projects/c++/modules/private_module/xmake.lua index 1930f1188..57ede6993 100644 --- a/tests/projects/c++/modules/private_module/xmake.lua +++ b/tests/projects/c++/modules/private_module/xmake.lua @@ -1,5 +1,6 @@ add_rules("mode.release", "mode.debug") set_languages("c++20") + target("private_module") add_rules("c++") set_kind("$(kind)") diff --git a/tests/projects/c++/modules/staticlib/xmake.lua b/tests/projects/c++/modules/staticlib/xmake.lua index 93045c18f..5a3a9f4c6 100644 --- a/tests/projects/c++/modules/staticlib/xmake.lua +++ b/tests/projects/c++/modules/staticlib/xmake.lua @@ -1,10 +1,11 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") target("mod") set_kind("static") add_files("src/mod.mpp", "src/mod.cpp") -target("test") +target("staticlib") set_kind("binary") add_deps("mod") add_files("src/main.cpp") diff --git a/tests/projects/c++/modules/stdmodules/test.lua b/tests/projects/c++/modules/stdmodules/test.lua index 0657ead56..e77adc4ae 100644 --- a/tests/projects/c++/modules/stdmodules/test.lua +++ b/tests/projects/c++/modules/stdmodules/test.lua @@ -1 +1 @@ -inherit(".test_msvc") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua index 85e738d14..134aee26c 100644 --- a/tests/projects/c++/modules/stdmodules/xmake.lua +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -1,14 +1,11 @@ add_rules("mode.debug", "mode.release") - -add_cxxflags("clang::-stdlib=libc++") - set_languages("c++latest") target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") -target("test") +target("stdmodules") set_kind("binary") add_files("test/*.cpp") add_deps("mod") diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua index 0657ead56..e77adc4ae 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/test.lua @@ -1 +1 @@ -inherit(".test_msvc") +inherit(".test_stdmodules") diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua index 859dddc7c..61d451908 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua @@ -1,7 +1,4 @@ add_rules("mode.debug", "mode.release") - -add_cxxflags("clang::-stdlib=libc++") - set_languages("c++latest") target("mod") diff --git a/tests/projects/c++/modules/stl_headerunit/xmake.lua b/tests/projects/c++/modules/stl_headerunit/xmake.lua index e85378c46..b73913a87 100644 --- a/tests/projects/c++/modules/stl_headerunit/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("stl_headerunit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it \ No newline at end of file diff --git a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua index 101a95fe7..03a6168b0 100644 --- a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua @@ -1,76 +1,9 @@ -add_rules("mode.debug", "mode.release") +add_rules("mode.release", "mode.debug") + set_languages("c++20") -target("test") +target("stl_headerunit_cpp_only") set_kind("binary") add_files("src/*.cpp") - set_languages("c++20") set_policy("build.c++.modules", true) --- --- If you want to known more usage about xmake, please see https://xmake.io --- --- ## FAQ --- --- You can enter the project directory firstly before building project. --- --- $ cd projectdir --- --- 1. How to build project? --- --- $ xmake --- --- 2. How to configure project? --- --- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release] --- --- 3. Where is the build output directory? --- --- The default output directory is `./build` and you can configure the output directory. --- --- $ xmake f -o outputdir --- $ xmake --- --- 4. How to run and debug target after building project? --- --- $ xmake run [targetname] --- $ xmake run -d [targetname] --- --- 5. How to install target to the system directory or other output directory? --- --- $ xmake install --- $ xmake install -o installdir --- --- 6. Add some frequently-used compilation flags in xmake.lua --- --- @code --- -- add debug and release modes --- add_rules("mode.debug", "mode.release") --- --- -- add macro defination --- add_defines("NDEBUG", "_GNU_SOURCE=1") --- --- -- set warning all as error --- set_warnings("all", "error") --- --- -- set language: c99, c++11 --- set_languages("c99", "c++11") --- --- -- set optimization: none, faster, fastest, smallest --- set_optimize("fastest") --- --- -- add include search directories --- add_includedirs("/usr/include", "/usr/local/include") --- --- -- add link libraries and search directories --- add_links("tbox") --- add_linkdirs("/usr/local/lib", "/usr/lib") --- --- -- add system link libraries --- add_syslinks("z", "pthread") --- --- -- add compilation and link flags --- add_cxflags("-stdnolib", "-fno-strict-aliasing") --- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true}) --- --- @endcode --- + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it diff --git a/tests/projects/c++/modules/submodules/xmake.lua b/tests/projects/c++/modules/submodules/xmake.lua index 672034947..5f2b4ca78 100644 --- a/tests/projects/c++/modules/submodules/xmake.lua +++ b/tests/projects/c++/modules/submodules/xmake.lua @@ -1,4 +1,8 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("submodule") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ diff --git a/tests/projects/c++/modules/submodules2/xmake.lua b/tests/projects/c++/modules/submodules2/xmake.lua index 672034947..9dc2ee320 100644 --- a/tests/projects/c++/modules/submodules2/xmake.lua +++ b/tests/projects/c++/modules/submodules2/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") -target("math") + +target("submodules2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 580110cb6..6ac816d66 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -14,7 +14,7 @@ function main(t) if is_subhost("windows") then os.exec("xmake f -c") _build() - elseif is_host("linux") then + elseif is_host("linux") or is_host("macos") then local gcc = find_tool("gcc", {version = true}) if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then os.exec("xmake f -c") @@ -22,9 +22,11 @@ function main(t) end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c") - _build() + if is_host("linux") then + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c") + _build() + end os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") _build() diff --git a/tests/projects/c++/modules/test_headerunits.lua b/tests/projects/c++/modules/test_headerunits.lua index 872defb35..747ec6535 100644 --- a/tests/projects/c++/modules/test_headerunits.lua +++ b/tests/projects/c++/modules/test_headerunits.lua @@ -26,10 +26,13 @@ function main(t) end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "16.0") >= 0 then - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c") - _build() - -- os.exec("xmake clean -a") there is currently a bug on llvm git that prevent to build STL header units https://github.com/llvm/llvm-project/issues/58540 + if is_host("linux") then + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c") + _build() + end + -- there is currently a bug on llvm git that prevent to build STL header units https://github.com/llvm/llvm-project/issues/58540 + -- os.exec("xmake clean -a") -- os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") -- _build() end diff --git a/tests/projects/c++/modules/test_msvc.lua b/tests/projects/c++/modules/test_msvc.lua deleted file mode 100644 index a436b5814..000000000 --- a/tests/projects/c++/modules/test_msvc.lua +++ /dev/null @@ -1,28 +0,0 @@ -import("lib.detect.find_tool") -import("core.base.semver") -import("core.tool.toolchain") - -function _build() - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then - os.exec("xmake -rvD") - else - os.exec("xmake -r") - end -end - -function main(t) - if is_subhost("windows") then - local msvc = toolchain.load("msvc") - if msvc and msvc:check() then - local vcvars = msvc:config("vcvars") - if vcvars and vcvars.VCInstallDir and vcvars.VCToolsVersion and semver.compare(vcvars.VCToolsVersion, "14.35") then - local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") - if os.isdir(stdmodulesdir) then - os.exec("xmake f -c") - _build() - end - end - end - end -end diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua new file mode 100644 index 000000000..2d8861d09 --- /dev/null +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -0,0 +1,47 @@ +import("lib.detect.find_tool") +import("core.base.semver") +import("core.tool.toolchain") + +function _build() + local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() + if ci == "true" then + os.exec("xmake -rvD") + else + os.exec("xmake -r") + end +end + +function main(t) + if is_subhost("windows") then + local msvc = toolchain.load("msvc") + if msvc and msvc:check() then + local vcvars = msvc:config("vcvars") + if vcvars and vcvars.VCInstallDir and vcvars.VCToolsVersion and semver.compare(vcvars.VCToolsVersion, "14.35") then + local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") + if os.isdir(stdmodulesdir) then + os.exec("xmake f -c") + _build() + end + end + end + elseif is_host("linux") or is_host("macos") then + -- gcc don't support std modules atm + -- local gcc = find_tool("gcc", {version = true}) + -- if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + -- os.exec("xmake f -c") + -- _build() + -- end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + if is_host("linux") then + -- clang don't support libstdc++ std modules atm + -- os.exec("xmake clean -a") + -- os.exec("xmake f --toolchain=clang -c") + -- _build() + end + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") + _build() + end + end +end diff --git a/tests/projects/c++/modules/user_headerunit/xmake.lua b/tests/projects/c++/modules/user_headerunit/xmake.lua index dae91d11f..e305044b5 100644 --- a/tests/projects/c++/modules/user_headerunit/xmake.lua +++ b/tests/projects/c++/modules/user_headerunit/xmake.lua @@ -1,4 +1,6 @@ +add_rules("mode.release", "mode.debug") set_languages("c++20") + target("user_headerunit") set_kind("binary") add_headerfiles("src/*.hpp") diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 9cf7edcdf..7a63c027d 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -67,11 +67,19 @@ end -- load module support for the current target function load(target) local modulesflag = get_modulesflag(target) + local builtinmodulemapflag = get_builtinmodulemapflag(target) + local implicitmodulesflag = get_implicitmodulesflag(target) local noimplicitmodulemapsflag = get_noimplicitmodulemapsflag(target) -- add module flags target:add("cxxflags", modulesflag) - target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) + + if not target:values("c++.clang.modules.strict") then + target:add("cxxflags", builtinmodulemapflag, {force = true}) + target:add("cxxflags", implicitmodulesflag, {force = true}) + else + target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) + end -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file -- module.pcm cannot be loaded due to a configuration mismatch with the current compilation. -- cgit v1.3.1 From d20bf041ae327176e2105ceca24b0089798477a1 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sat, 7 Jan 2023 19:18:18 +0100 Subject: fix on macos fix on macos --- tests/projects/c++/modules/test_base.lua | 12 +++++------- tests/projects/c++/modules/test_stdmodules.lua | 14 ++++++------- xmake/rules/c++/modules/modules_support/clang.lua | 24 +++++++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/projects/c++/modules/test_base.lua b/tests/projects/c++/modules/test_base.lua index 6ac816d66..efef15520 100644 --- a/tests/projects/c++/modules/test_base.lua +++ b/tests/projects/c++/modules/test_base.lua @@ -14,19 +14,17 @@ function main(t) if is_subhost("windows") then os.exec("xmake f -c") _build() - elseif is_host("linux") or is_host("macos") then + elseif is_host("linux") then local gcc = find_tool("gcc", {version = true}) - if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then os.exec("xmake f -c") _build() end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then - if is_host("linux") then - os.exec("xmake clean -a") - os.exec("xmake f --toolchain=clang -c") - _build() - end + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c") + _build() os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") _build() diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index 2d8861d09..621f0b1d4 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -24,21 +24,19 @@ function main(t) end end end - elseif is_host("linux") or is_host("macos") then + elseif is_host("linux") then -- or is_host("macos") then -- gcc don't support std modules atm -- local gcc = find_tool("gcc", {version = true}) - -- if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + -- if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then -- os.exec("xmake f -c") -- _build() -- end local clang = find_tool("clang", {version = true}) if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then - if is_host("linux") then - -- clang don't support libstdc++ std modules atm - -- os.exec("xmake clean -a") - -- os.exec("xmake f --toolchain=clang -c") - -- _build() - end + -- clang don't support libstdc++ std modules atm + -- os.exec("xmake clean -a") + -- os.exec("xmake f --toolchain=clang -c") + -- _build() os.exec("xmake clean -a") os.exec("xmake f --toolchain=clang --cxxflags=\"-stdlib=libc++\" -c") _build() diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 7a63c027d..129221e5d 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -66,13 +66,16 @@ end -- load module support for the current target function load(target) - local modulesflag = get_modulesflag(target) + local modulesflag, modulestsflag = get_modulesflag(target) local builtinmodulemapflag = get_builtinmodulemapflag(target) local implicitmodulesflag = get_implicitmodulesflag(target) local noimplicitmodulemapsflag = get_noimplicitmodulemapsflag(target) -- add module flags target:add("cxxflags", modulesflag) + if not modulesflag or is_host("macos") then + target:add("cxxflags", modulestsflag) + end if not target:values("c++.clang.modules.strict") then target:add("cxxflags", builtinmodulemapflag, {force = true}) @@ -583,20 +586,20 @@ end function get_modulesflag(target) local modulesflag = _g.modulesflag - if modulesflag == nil then + local modulestsflag = _g.modulestsflag + if modulesflag == nil and modulestsflag == nil then local compinst = target:compiler("cxx") if compinst:has_flags("-fmodules", "cxxflags", {flagskey = "clang_modules"}) then modulesflag = "-fmodules" end - if not modulesflag then - if compinst:has_flags("-fmodules-ts", "cxxflags", {flagskey = "clang_modules_ts"}) then - modulesflag = "-fmodules-ts" - end + if compinst:has_flags("-fmodules-ts", "cxxflags", {flagskey = "clang_modules_ts"}) then + modulestsflag = "-fmodules-ts" end - assert(modulesflag, "compiler(clang): does not support c++ module!") + assert(modulesflag or modulestsflag, "compiler(clang): does not support c++ module!") _g.modulesflag = modulesflag or false + _g.modulestsflag = modulestsflag or false end - return modulesflag or nil + return modulesflag or nil, modulestsflag or nil end function get_builtinmodulemapflag(target) @@ -698,8 +701,9 @@ function has_headerunitsupport(target) local support_headerunits = _g.support_headerunits if support_headerunits == nil then local compinst = target:compiler("cxx") - if compinst:has_flags(get_modulesflag(target) .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and - compinst:has_flags(get_modulesflag(target) .. " -std=c++20 -x c++-system-header", "cxxflags", {flagskey = "clang_system_header_unit_support", tryrun = true}) then + local modulesflag, modulestsflag = get_modulesflag(target) + if compinst:has_flags(modulesflag or moduletsflag .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and + compinst:has_flags(modulesflag or moduletsflag .. " -std=c++20 -x c++-system-header", "cxxflags", {flagskey = "clang_system_header_unit_support", tryrun = true}) then support_headerunits = true end _g.support_headerunits = support_headerunits or false -- cgit v1.3.1 From 0922b353dec8370bbbfb130bdabc4ac123c170ab Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 8 Jan 2023 10:31:03 +0800 Subject: Update xmake.lua --- tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua index 03a6168b0..73ba6b99b 100644 --- a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua @@ -1,9 +1,8 @@ add_rules("mode.release", "mode.debug") - set_languages("c++20") target("stl_headerunit_cpp_only") set_kind("binary") add_files("src/*.cpp") + set_languages("c++20") set_policy("build.c++.modules", true) - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it -- cgit v1.3.1 From ba5101263cc13bd51e8d22616e1a315e95e652ed Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 8 Jan 2023 10:31:41 +0800 Subject: Update xmake.lua --- tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua index 73ba6b99b..7b8a04f2e 100644 --- a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua @@ -1,8 +1,8 @@ add_rules("mode.release", "mode.debug") +set_languages("c++20") target("stl_headerunit_cpp_only") set_kind("binary") add_files("src/*.cpp") - set_languages("c++20") set_policy("build.c++.modules", true) set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it -- cgit v1.3.1 From d063da2c62159e5894f44c7bbef749eec3e465d8 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 8 Jan 2023 10:33:15 +0800 Subject: Update clang.lua --- xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 129221e5d..671643165 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -73,7 +73,7 @@ function load(target) -- add module flags target:add("cxxflags", modulesflag) - if not modulesflag or is_host("macos") then + if not modulesflag or is_host("macosx") then target:add("cxxflags", modulestsflag) end -- cgit v1.3.1 From 80f582eb5af42fa9121f6bb294d2d4952140b046 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 8 Jan 2023 10:34:13 +0800 Subject: Update test_stdmodules.lua --- tests/projects/c++/modules/test_stdmodules.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/projects/c++/modules/test_stdmodules.lua b/tests/projects/c++/modules/test_stdmodules.lua index 621f0b1d4..360a56cbc 100644 --- a/tests/projects/c++/modules/test_stdmodules.lua +++ b/tests/projects/c++/modules/test_stdmodules.lua @@ -24,7 +24,7 @@ function main(t) end end end - elseif is_host("linux") then -- or is_host("macos") then + elseif is_host("linux") then -- or is_host("macosx") then -- gcc don't support std modules atm -- local gcc = find_tool("gcc", {version = true}) -- if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then -- cgit v1.3.1 From c394913eafbc3a24485a0c88b0d891e9954b302b Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 8 Jan 2023 10:41:31 +0800 Subject: Update clang.lua --- xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 671643165..34ee9a2ac 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -73,7 +73,7 @@ function load(target) -- add module flags target:add("cxxflags", modulesflag) - if not modulesflag or is_host("macosx") then + if not modulesflag or target:is_plat("macosx") then target:add("cxxflags", modulestsflag) end -- cgit v1.3.1 From 4f4c744e7b7090ee3b33f98b8d07d36fd9f81db0 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 8 Jan 2023 17:34:35 +0100 Subject: fallback on clang modules when c++.clang.modules.strict is not set for std modules --- xmake/rules/c++/modules/modules_support/clang.lua | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 0e91aadae..a81dd01f7 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -275,6 +275,35 @@ function generate_dependencies(target, sourcebatch, opt) changed = true local dependinfo = io.readfile(jsonfile) + if not target:data("cxx.modules.use_libc++") then + local has_std_modules = false + for _, r in ipairs (dependinfo.rules) do + for _, required in ipairs(r.requires) do + if required["logical-name"] == "std" or required["logical-name"] == "std.compat" then + has_std_modules = true + break + end + end + + if has_std_modules then + break + end + end + + assert(not (has_std_modules and target:values("c++.clang.modules.strict")), + [[On llvm <= 16 standard C++ modules are not supported ; + they can be emulated through clang modules and supported only on libc++ ; + please add -stdlib=libc++ cxx flag or disable strict mode]]) + + if has_std_modules then + target:data_set("cxx.modules.use_libc++", true) + if target:data("cxx.modules.use_libc++") then + target:add("cxxflags", "-stdlib=libc++") + target:add("syslinks", "c++") + end + end + end + return {moduleinfo = dependinfo} end, {dependfile = dependfile, files = {sourcefile}}) end -- cgit v1.3.1 From 20dcec10367cbad48bb9b7c400761a5c45dd7e47 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 10 Jan 2023 15:51:18 +0100 Subject: fix clang std modules enabled --- tests/projects/c++/modules/impl_unit/xmake.lua | 2 - tests/projects/c++/modules/partitions/xmake.lua | 4 +- xmake/rules/c++/modules/modules_support/clang.lua | 62 +++++++++++++---------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/tests/projects/c++/modules/impl_unit/xmake.lua b/tests/projects/c++/modules/impl_unit/xmake.lua index 64db3cf8c..991f2a895 100644 --- a/tests/projects/c++/modules/impl_unit/xmake.lua +++ b/tests/projects/c++/modules/impl_unit/xmake.lua @@ -4,5 +4,3 @@ set_languages("c++20") target("impl_unit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/partitions/xmake.lua b/tests/projects/c++/modules/partitions/xmake.lua index 68602dce4..4b575432a 100644 --- a/tests/projects/c++/modules/partitions/xmake.lua +++ b/tests/projects/c++/modules/partitions/xmake.lua @@ -3,6 +3,4 @@ set_languages("c++20") target("partition") set_kind("binary") - add_files("src/*.cpp", "src/*.mpp") - - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file + add_files("src/*.cpp", "src/*.mpp") \ No newline at end of file diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index a81dd01f7..7d843c3dd 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -65,6 +65,12 @@ function _get_modulemap_from_mapper(target, name) return common.localcache():get2(_mapper_cachekey(target), "modulemap" .. name) or nil end +-- enable libc++ +function _enable_libcxx(target) + target:add("cxxflags", "-stdlib=libc++") + target:add("syslinks", "c++") +end + -- load module support for the current target function load(target) local modulesflag, modulestsflag = get_modulesflag(target) @@ -82,7 +88,7 @@ function load(target) target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", implicitmodulesflag, {force = true}) else - target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) + target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) end -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file @@ -110,7 +116,7 @@ function load(target) local flags = table.join(target:get("cxxflags"), get_config("cxxflags") or {}) target:data_set("cxx.modules.use_libc++", table.contains(flags, "-stdlib=libc++", "clang::-stdlib=libc++")) if target:data("cxx.modules.use_libc++") then - target:add("syslinks", "c++") + _enable_libcxx(target) end end @@ -179,7 +185,7 @@ function _build_modulefile(target, sourcefile, opt) local bmiflags if opt.provide then bmifile = opt.provide.bmifile - bmiflags = table.join("-x", "c++-module", "--precompile", compflags, common_args, requiresflags or {}) + bmiflags = table.join("-x", "c++-module", "--precompile", compflags, common_args, requiresflags) vprint(compinst:compcmd(sourcefile, bmifile, {compflags = bmiflags, rawargs = true})) end @@ -274,37 +280,39 @@ function generate_dependencies(target, sourcebatch, opt) end) changed = true - local dependinfo = io.readfile(jsonfile) - if not target:data("cxx.modules.use_libc++") then - local has_std_modules = false - for _, r in ipairs (dependinfo.rules) do - for _, required in ipairs(r.requires) do - if required["logical-name"] == "std" or required["logical-name"] == "std.compat" then - has_std_modules = true - break + local rawdependinfo = io.readfile(jsonfile) + if rawdependinfo then + local dependinfo = json.decode(rawdependinfo) + if not target:data("cxx.modules.use_libc++") then + local has_std_modules = false + for _, r in ipairs(dependinfo.rules) do + for _, required in ipairs(r.requires) do + if required["logical-name"] == "std" or required["logical-name"] == "std.compat" then + has_std_modules = true + break + end end - end - if has_std_modules then - break + if has_std_modules then + break + end end - end - assert(not (has_std_modules and target:values("c++.clang.modules.strict")), - [[On llvm <= 16 standard C++ modules are not supported ; - they can be emulated through clang modules and supported only on libc++ ; - please add -stdlib=libc++ cxx flag or disable strict mode]]) + assert(not (has_std_modules and target:values("c++.clang.modules.strict")), + [[On llvm <= 16 standard C++ modules are not supported ; + they can be emulated through clang modules and supported only on libc++ ; + please add -stdlib=libc++ cxx flag or disable strict mode]]) - if has_std_modules then - target:data_set("cxx.modules.use_libc++", true) - if target:data("cxx.modules.use_libc++") then - target:add("cxxflags", "-stdlib=libc++") - target:add("syslinks", "c++") + if has_std_modules then + target:data_set("cxx.modules.use_libc++", true) + if target:data("cxx.modules.use_libc++") then + _enable_libcxx(target) + end end end end - return {moduleinfo = dependinfo} + return {moduleinfo = rawdependinfo} end, {dependfile = dependfile, files = {sourcefile}}) end return changed @@ -798,7 +806,7 @@ function get_requiresflags(target, requires) already_mapped_modules[name] = true table.insert(flags, modulemap_.flag) if modulemap_.deps then - table.shallow_join2(flags, modulemap_.deps) + table.join2(flags, modulemap_.deps) end goto continue end @@ -810,7 +818,7 @@ function get_requiresflags(target, requires) already_mapped_modules[name] = true table.insert(flags, modulemap.flag) if modulemap.deps then - table.shallow_join2(flags, modulemap.deps) + table.join2(flags, modulemap.deps) end goto continue end -- cgit v1.3.1 From 4649cb58b79453c8f3a6b5277125d2f8ece9c233 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 14:10:14 +0100 Subject: cleanup --- tests/projects/c++/modules/dependence/xmake.lua | 4 +--- tests/projects/c++/modules/link_order/xmake.lua | 5 ----- tests/projects/c++/modules/partitions2/xmake.lua | 2 -- tests/projects/c++/modules/submodules/xmake.lua | 2 -- 4 files changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/projects/c++/modules/dependence/xmake.lua b/tests/projects/c++/modules/dependence/xmake.lua index b4ecdb1b9..16e47a55d 100644 --- a/tests/projects/c++/modules/dependence/xmake.lua +++ b/tests/projects/c++/modules/dependence/xmake.lua @@ -5,6 +5,4 @@ target("dependence") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - if has_config("libc++") then - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ - end \ No newline at end of file + set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/link_order/xmake.lua b/tests/projects/c++/modules/link_order/xmake.lua index c6310055c..6a11418ac 100644 --- a/tests/projects/c++/modules/link_order/xmake.lua +++ b/tests/projects/c++/modules/link_order/xmake.lua @@ -1,8 +1,3 @@ -option("libc++") - set_default(false) - set_showmenu(true) -option_end() - add_rules("mode.release", "mode.debug") set_languages("c++20") diff --git a/tests/projects/c++/modules/partitions2/xmake.lua b/tests/projects/c++/modules/partitions2/xmake.lua index 1dfd2321b..9e0ab37bb 100644 --- a/tests/projects/c++/modules/partitions2/xmake.lua +++ b/tests/projects/c++/modules/partitions2/xmake.lua @@ -4,5 +4,3 @@ set_languages("c++20") target("partition2") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ diff --git a/tests/projects/c++/modules/submodules/xmake.lua b/tests/projects/c++/modules/submodules/xmake.lua index 5f2b4ca78..e84b63a9f 100644 --- a/tests/projects/c++/modules/submodules/xmake.lua +++ b/tests/projects/c++/modules/submodules/xmake.lua @@ -4,5 +4,3 @@ set_languages("c++20") target("submodule") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ -- cgit v1.3.1 From 429ff39f5874e63741aecbe3dfdc15d790e0fb44 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 14:47:19 +0100 Subject: rename clang std modulemap enabler and disable it by default --- tests/projects/c++/modules/class/xmake.lua | 2 +- tests/projects/c++/modules/dependence/xmake.lua | 1 - tests/projects/c++/modules/headerunits_person/xmake.lua | 1 - tests/projects/c++/modules/inline_and_template/xmake.lua | 1 - tests/projects/c++/modules/stdmodules/xmake.lua | 4 ++++ tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua | 4 ++++ xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 7 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/projects/c++/modules/class/xmake.lua b/tests/projects/c++/modules/class/xmake.lua index 2dfca344c..42da78369 100644 --- a/tests/projects/c++/modules/class/xmake.lua +++ b/tests/projects/c++/modules/class/xmake.lua @@ -5,4 +5,4 @@ target("class") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ + diff --git a/tests/projects/c++/modules/dependence/xmake.lua b/tests/projects/c++/modules/dependence/xmake.lua index 16e47a55d..4d035c42b 100644 --- a/tests/projects/c++/modules/dependence/xmake.lua +++ b/tests/projects/c++/modules/dependence/xmake.lua @@ -5,4 +5,3 @@ target("dependence") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/headerunits_person/xmake.lua b/tests/projects/c++/modules/headerunits_person/xmake.lua index 93b635988..d11b49824 100644 --- a/tests/projects/c++/modules/headerunits_person/xmake.lua +++ b/tests/projects/c++/modules/headerunits_person/xmake.lua @@ -5,4 +5,3 @@ target("headerunits_person") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it \ No newline at end of file diff --git a/tests/projects/c++/modules/inline_and_template/xmake.lua b/tests/projects/c++/modules/inline_and_template/xmake.lua index 57635eff3..8c981fae9 100644 --- a/tests/projects/c++/modules/inline_and_template/xmake.lua +++ b/tests/projects/c++/modules/inline_and_template/xmake.lua @@ -5,4 +5,3 @@ target("inline_and_template") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl headers, header units and c++23 std module so we disable it when using libc++ \ No newline at end of file diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua index 134aee26c..8007553ed 100644 --- a/tests/projects/c++/modules/stdmodules/xmake.lua +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -5,7 +5,11 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") + set_values("c++.clang.module.stdmodules", true) + target("stdmodules") set_kind("binary") add_files("test/*.cpp") add_deps("mod") + + set_values("c++.clang.module.stdmodules", true) diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua index 61d451908..330fa56f8 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua @@ -5,6 +5,10 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") + set_values("c++.clang.module.stdmodules", true) + target("mod2") set_kind("static") add_files("src/*.cpp", "src/*.mpp") + + set_values("c++.clang.module.stdmodules", true) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 7d843c3dd..19f6968c6 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -84,7 +84,7 @@ function load(target) target:add("cxxflags", modulestsflag) end - if not target:values("c++.clang.modules.strict") then + if target:values("c++.clang.modules.stdmodules") then target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", implicitmodulesflag, {force = true}) else -- cgit v1.3.1 From a70a59a68f39d9c9ba3538baa94dcce6132f1241 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 15:38:52 +0100 Subject: cleanup --- tests/projects/c++/modules/stl_headerunit/xmake.lua | 1 - tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua | 2 +- xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/projects/c++/modules/stl_headerunit/xmake.lua b/tests/projects/c++/modules/stl_headerunit/xmake.lua index b73913a87..55d55a5fd 100644 --- a/tests/projects/c++/modules/stl_headerunit/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit/xmake.lua @@ -5,4 +5,3 @@ target("stl_headerunit") set_kind("binary") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it \ No newline at end of file diff --git a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua index 7b8a04f2e..97a260e1e 100644 --- a/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua +++ b/tests/projects/c++/modules/stl_headerunit_cpp_only/xmake.lua @@ -5,4 +5,4 @@ target("stl_headerunit_cpp_only") set_kind("binary") add_files("src/*.cpp") set_policy("build.c++.modules", true) - set_values("c++.clang.modules.strict", true) -- clang std module clash with stl header units or c++23 std module so we disable it + diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 19f6968c6..74b2f62cc 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -298,7 +298,7 @@ function generate_dependencies(target, sourcebatch, opt) end end - assert(not (has_std_modules and target:values("c++.clang.modules.strict")), + assert(not (has_std_modules and not target:values("c++.clang.modules.stdmodules")), [[On llvm <= 16 standard C++ modules are not supported ; they can be emulated through clang modules and supported only on libc++ ; please add -stdlib=libc++ cxx flag or disable strict mode]]) -- cgit v1.3.1 From 98e4399340bca560915c8faef19a632840046a0e Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 17:31:14 +0100 Subject: use policies instead of target values --- tests/projects/c++/modules/stdmodules/xmake.lua | 4 ++-- tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua | 4 ++-- xmake/core/project/policy.lua | 2 ++ xmake/rules/c++/modules/modules_support/clang.lua | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua index 8007553ed..496961cd0 100644 --- a/tests/projects/c++/modules/stdmodules/xmake.lua +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -5,11 +5,11 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.module.stdmodules", true) + set_policy("c++.clang.module.stdmodules", true) target("stdmodules") set_kind("binary") add_files("test/*.cpp") add_deps("mod") - set_values("c++.clang.module.stdmodules", true) + set_policy("c++.clang.module.stdmodules", true) diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua index 330fa56f8..3501597ff 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua @@ -5,10 +5,10 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.module.stdmodules", true) + set_policy("c++.clang.module.stdmodules", true) target("mod2") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_values("c++.clang.module.stdmodules", true) + set_policy("c++.clang.module.stdmodules", true) diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 8148a37e2..ac93415f9 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -35,6 +35,8 @@ function policy.policies() if not policies then policies = { + -- enable clang std modulemap + ["c++.clang.module.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"}, -- we will check and ignore all unsupported flags by default, but we can also pass `{force = true}` to force to set flags, e.g. add_ldflags("-static", {force = true}) ["check.auto_ignore_flags"] = {description = "Enable check and ignore unsupported flags automatically.", default = true, type = "boolean"}, -- we will map gcc flags to the current compiler and linker by default. diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 74b2f62cc..747c62166 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -84,7 +84,7 @@ function load(target) target:add("cxxflags", modulestsflag) end - if target:values("c++.clang.modules.stdmodules") then + if target:policy("c++.clang.module.stdmodules") then target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", implicitmodulesflag, {force = true}) else @@ -298,7 +298,7 @@ function generate_dependencies(target, sourcebatch, opt) end end - assert(not (has_std_modules and not target:values("c++.clang.modules.stdmodules")), + assert(not (has_std_modules and not target:policy("c++.clang.modules.stdmodules")), [[On llvm <= 16 standard C++ modules are not supported ; they can be emulated through clang modules and supported only on libc++ ; please add -stdlib=libc++ cxx flag or disable strict mode]]) -- cgit v1.3.1 From 1175f07e0ead7a1f8a5d9cb76d895e1ea9b01ad0 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 17:32:03 +0100 Subject: fix policy indent --- xmake/core/project/policy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index ac93415f9..4c0d1a793 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -36,7 +36,7 @@ function policy.policies() policies = { -- enable clang std modulemap - ["c++.clang.module.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"}, + ["c++.clang.module.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"}, -- we will check and ignore all unsupported flags by default, but we can also pass `{force = true}` to force to set flags, e.g. add_ldflags("-static", {force = true}) ["check.auto_ignore_flags"] = {description = "Enable check and ignore unsupported flags automatically.", default = true, type = "boolean"}, -- we will map gcc flags to the current compiler and linker by default. -- cgit v1.3.1 From 8a582f9a9fb7be2cfbfdd2f18f31510547dff12b Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Wed, 11 Jan 2023 17:58:02 +0100 Subject: rename clang std modulemap policy --- tests/projects/c++/modules/stdmodules/xmake.lua | 4 ++-- tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua | 4 ++-- xmake/core/project/policy.lua | 4 ++-- xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua index 496961cd0..5cf4ccb9d 100644 --- a/tests/projects/c++/modules/stdmodules/xmake.lua +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -5,11 +5,11 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_policy("c++.clang.module.stdmodules", true) + set_policy("build.c++.clang.stdmodules", true) target("stdmodules") set_kind("binary") add_files("test/*.cpp") add_deps("mod") - set_policy("c++.clang.module.stdmodules", true) + set_policy("build.c++.clang.stdmodules", true) diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua index 3501597ff..32bed613b 100644 --- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua +++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua @@ -5,10 +5,10 @@ target("mod") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_policy("c++.clang.module.stdmodules", true) + set_policy("build.c++.clang.stdmodules", true) target("mod2") set_kind("static") add_files("src/*.cpp", "src/*.mpp") - set_policy("c++.clang.module.stdmodules", true) + set_policy("build.c++.clang.stdmodules", true) diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 4c0d1a793..4c9f87cd1 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -35,8 +35,6 @@ function policy.policies() if not policies then policies = { - -- enable clang std modulemap - ["c++.clang.module.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"}, -- we will check and ignore all unsupported flags by default, but we can also pass `{force = true}` to force to set flags, e.g. add_ldflags("-static", {force = true}) ["check.auto_ignore_flags"] = {description = "Enable check and ignore unsupported flags automatically.", default = true, type = "boolean"}, -- we will map gcc flags to the current compiler and linker by default. @@ -55,6 +53,8 @@ function policy.policies() ["build.optimization.lto"] = {description = "Enable LTO linker-time optimization for c/c++ building.", type = "boolean"}, -- enable C++ modules for C++ building, even if no .mpp is involved in the compilation ["build.c++.modules"] = {description = "Enable C++ modules for C++ building.", type = "boolean"}, + -- enable clang std modulemap + ["build.c++.clang.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"}, -- preprocessor configuration for ccache/distcc, we can disable linemarkers to speed up preprocess ["preprocessor.linemarkers"] = {description = "Enable linemarkers for preprocessor.", default = true, type = "boolean"}, -- preprocessor configuration for ccache/distcc, we can disable it to avoid cache object file with __DATE__, __TIME__ diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 747c62166..30b27bc2a 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -84,7 +84,7 @@ function load(target) target:add("cxxflags", modulestsflag) end - if target:policy("c++.clang.module.stdmodules") then + if target:policy("build.c++.clang.stdmodules") then target:add("cxxflags", builtinmodulemapflag, {force = true}) target:add("cxxflags", implicitmodulesflag, {force = true}) else -- cgit v1.3.1 From 9793894c1d2e055a4cfe044002bea4c7e6bb075d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 12 Jan 2023 07:56:46 +0800 Subject: Update clang.lua --- xmake/rules/c++/modules/modules_support/clang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 30b27bc2a..4d1f07747 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -298,7 +298,7 @@ function generate_dependencies(target, sourcebatch, opt) end end - assert(not (has_std_modules and not target:policy("c++.clang.modules.stdmodules")), + assert(not (has_std_modules and not target:policy("build.c++.clang.stdmodules")), [[On llvm <= 16 standard C++ modules are not supported ; they can be emulated through clang modules and supported only on libc++ ; please add -stdlib=libc++ cxx flag or disable strict mode]]) -- cgit v1.3.1