diff options
| author | Arthur LAURENT <[email protected]> | 2023-02-14 18:45:42 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2023-02-15 18:13:26 +0100 |
| commit | 3cdbc4183fe807d2bf4bbcb19aef1f85e33c1d6d (patch) | |
| tree | 9b9c0d0ef8b2d28bec744a0df520be933b8939e1 /xmake/rules/c++ | |
| parent | e288951c41b72f3ccf3cfed495417fea7dee1e79 (diff) | |
remove useless flags to build modules on clang
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 763cfb6cd..54be2c80f 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -116,22 +116,16 @@ end -- load module support for the current target function load(target) - local modulesflag, modulestsflag = get_modulesflag(target) - local builtinmodulemapflag = get_builtinmodulemapflag(target) - local implicitmodulesflag = get_implicitmodulesflag(target) - local noimplicitmodulemapsflag = get_noimplicitmodulemapsflag(target) + local clangmodulesflag, modulestsflag, withoutflag = get_modulesflag(target) -- add module flags - target:add("cxxflags", modulesflag) - if not modulesflag then + if not withoutflag then target:add("cxxflags", modulestsflag) end + -- enable clang modules to emulate std modules if target:policy("build.c++.clang.stdmodules") then - target:add("cxxflags", builtinmodulemapflag, {force = true}) - target:add("cxxflags", implicitmodulesflag, {force = true}) - else - target:add("cxxflags", noimplicitmodulemapsflag, {force = true}) + target:add("cxxflags", clangmodulesflag) end -- fix default visibility for functions and variables [-fvisibility] differs in PCH file vs. current file @@ -698,21 +692,25 @@ function get_bmi_extension() end function get_modulesflag(target) - local modulesflag = _g.modulesflag + local clangmodulesflag = _g.clangmodulesflag local modulestsflag = _g.modulestsflag - if modulesflag == nil and modulestsflag == nil then + local withoutflag = _g.withoutflag + if clangmodulesflag == nil and modulestsflag == nil then local compinst = target:compiler("cxx") if compinst:has_flags("-fmodules", "cxxflags", {flagskey = "clang_modules"}) then - modulesflag = "-fmodules" + clangmodulesflag = "-fmodules" end if compinst:has_flags("-fmodules-ts", "cxxflags", {flagskey = "clang_modules_ts"}) then modulestsflag = "-fmodules-ts" end - assert(modulesflag or modulestsflag, "compiler(clang): does not support c++ module!") - _g.modulesflag = modulesflag or false + local clang_version = _get_clang_version(target) + withoutflag = semver.compare(clang_version, "16.0") >= 0 + assert(withoutflag or modulestsflag, "compiler(clang): does not support c++ module!") + _g.clangmodulesflag = clangmodulesflag or false _g.modulestsflag = modulestsflag or false + _g.withoutflag = withoutflag or false end - return modulesflag or nil, modulestsflag or nil + return clangmodulesflag or nil, modulestsflag or nil, withoutflag or nil end function get_builtinmodulemapflag(target) @@ -814,9 +812,10 @@ function has_headerunitsupport(target) local support_headerunits = _g.support_headerunits if support_headerunits == nil then local compinst = target:compiler("cxx") - local modulesflag, modulestsflag = get_modulesflag(target) - if compinst:has_flags(modulesflag or modulestsflag .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and - compinst:has_flags(modulesflag or modulestsflag .. " -std=c++20 -x c++-system-header", "cxxflags", {flagskey = "clang_system_header_unit_support", tryrun = true}) then + local _, modulestsflag, withoutflag = get_modulesflag(target) + modulestsflag = withoutflag and "" or modulestsflag + if compinst:has_flags(modulestsflag .. " -std=c++20 -x c++-user-header", "cxxflags", {flagskey = "clang_user_header_unit_support", tryrun = true}) and + compinst:has_flags(modulestsflag .. " -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 |
