diff options
Diffstat (limited to 'xmake/rules/c++/modules/clang/support.lua')
| -rw-r--r-- | xmake/rules/c++/modules/clang/support.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/xmake/rules/c++/modules/clang/support.lua b/xmake/rules/c++/modules/clang/support.lua index 71bd2e735..a010fdde1 100644 --- a/xmake/rules/c++/modules/clang/support.lua +++ b/xmake/rules/c++/modules/clang/support.lua @@ -130,6 +130,13 @@ function has_two_phase_compilation_support(target) return target:policy("build.c++.modules.two_phases") end +function has_precompile_reduced_bmi_support(target) + if not target:policy("build.c++.modules.clang.precompile_reduced_bmi") or not has_two_phase_compilation_support(target) then + return false + end + return get_modulesprecompilereducedbmiflag(target) ~= nil +end + -- flags that doesn't affect bmi generation function strippeable_flags() -- speculative list as there is no resource that list flags that prevent reusability, this list will likely be improve over time @@ -411,6 +418,25 @@ function get_modulesreducedbmiflag(target) return modulesreducedbmiflag or nil end +function get_modulesprecompilereducedbmiflag(target) + local modulesprecompilereducedbmiflag = _g.modulesprecompilereducedbmiflag + if modulesprecompilereducedbmiflag == nil then + local compinst = target:compiler("cxx") + local checkflags = "--precompile-reduced-bmi" + if target:has_tool("cxx", "clang_cl") then + -- clang_cl.has_flags() appends -c and treats unused-argument warnings as errors, + -- but --precompile-reduced-bmi does not use -c. Ignore that specific warning and + -- treat unknown-argument warnings as errors to reject unsupported flags. + checkflags = {checkflags, "-Wno-unused-command-line-argument", "-Werror=unknown-argument"} + end + if compinst:has_flags(checkflags, "cxxflags", {flagskey = "clang_modules_precompile_reduced_bmi", tryrun = true}) then + modulesprecompilereducedbmiflag = "--precompile-reduced-bmi" + end + _g.modulesprecompilereducedbmiflag = modulesprecompilereducedbmiflag or false + end + return modulesprecompilereducedbmiflag or nil +end + function has_clangscandepssupport(target) local support_clangscandeps = _g.support_clangscandeps if support_clangscandeps == nil then |
