summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2023-01-08 17:34:35 +0100
committerArthur LAURENT <[email protected]>2023-01-08 17:37:21 +0100
commit4f4c744e7b7090ee3b33f98b8d07d36fd9f81db0 (patch)
treefc93fa2e90943bcf8875fffba58b3eef898d16d5
parent8749422a005d5150fccbfe807fbc618361a2afa1 (diff)
fallback on clang modules when c++.clang.modules.strict is not set for std modules
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua29
1 files changed, 29 insertions, 0 deletions
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