diff options
| author | Arthur LAURENT <[email protected]> | 2025-05-11 16:35:26 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-05-11 16:35:26 +0200 |
| commit | e1cf8f6a8c4457b0a77e5f2f16fbf5e73252dd50 (patch) | |
| tree | 94ed745fa7fa1c3d6b6a52621cafbd0d667cd33a | |
| parent | 6b69dfdfb023221a250e3f1419ece29a78841b34 (diff) | |
(C++ modules support) add support of libstdc++ std module for clang/llvm
| -rw-r--r-- | xmake/rules/c++/modules/clang/support.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/gcc/support.lua | 31 |
2 files changed, 22 insertions, 15 deletions
diff --git a/xmake/rules/c++/modules/clang/support.lua b/xmake/rules/c++/modules/clang/support.lua index fd27bcb96..9ae1754e6 100644 --- a/xmake/rules/c++/modules/clang/support.lua +++ b/xmake/rules/c++/modules/clang/support.lua @@ -277,7 +277,11 @@ function get_stdmodules(target) end end elseif cpplib == "stdc++" then - -- libstdc++ doesn't have a std module file atm + -- dont be greedy and don't enable stdc++ std module support for llvm < 19 + local clang_version = get_clang_version(target) + if clang_version and semver.compare(clang_version, "19.0") >= 0 then + return import(".gcc.support").get_stdmodules(target, {warn = false}) + end elseif cpplib == "msstl" then -- msstl std module file is not compatible with llvm < 19 local clang_version = get_clang_version(target) diff --git a/xmake/rules/c++/modules/gcc/support.lua b/xmake/rules/c++/modules/gcc/support.lua index 25b664b86..e28ff2046 100644 --- a/xmake/rules/c++/modules/gcc/support.lua +++ b/xmake/rules/c++/modules/gcc/support.lua @@ -166,26 +166,29 @@ function _get_std_module_manifest_path(target) end end -function get_stdmodules(target) +function get_stdmodules(target, opt) + opt = opt or {} if not target:policy("build.c++.modules.std") then return end local modules_json_path = _get_std_module_manifest_path(target) - if not modules_json_path then - return - end - local modules_json = json.loadfile(modules_json_path) - if modules_json and modules_json.modules and #modules_json.modules > 0 then - local std_module_files = {} - local modules_json_dir = path.directory(modules_json_path) - for _, module_file in ipairs(modules_json.modules) do - local module_file_path = module_file["source-path"] - if not path.is_absolute(module_file_path) then - module_file_path = path.join(modules_json_dir, module_file_path) + if modules_json_path then + local modules_json = json.loadfile(modules_json_path) + if modules_json and modules_json.modules and #modules_json.modules > 0 then + local std_module_files = {} + local modules_json_dir = path.directory(modules_json_path) + for _, module_file in ipairs(modules_json.modules) do + local module_file_path = module_file["source-path"] + if not path.is_absolute(module_file_path) then + module_file_path = path.join(modules_json_dir, module_file_path) + end + table.insert(std_module_files, path.normalize(module_file_path)) end - table.insert(std_module_files, path.normalize(module_file_path)) + return std_module_files end - return std_module_files + end + if not opt.dont_warn then + wprint("std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++") end end |
