diff options
| author | ruki <[email protected]> | 2026-07-09 21:41:07 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-09 21:41:07 +0800 |
| commit | 3a0b131873815ff3c2d4d133885f1e691823e945 (patch) | |
| tree | 08e0135428a263f76ea9c5918b0a874279f64570 | |
| parent | 03e4bc9076d6cd9e642f4a9c565c85757db72ce2 (diff) | |
| parent | fa23c322f7e7f1944420cae964bc8f6a6c99b811 (diff) | |
Merge pull request #7563 from xmake-io/modules
improve pch for std modules
| -rw-r--r-- | xmake/modules/core/tools/filcc/features.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/core/tools/filcc/has_flags.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/core/tools/filxx/features.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/core/tools/filxx/has_flags.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 6 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/support.lua | 16 |
6 files changed, 109 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/filcc/features.lua b/xmake/modules/core/tools/filcc/features.lua new file mode 100644 index 000000000..9b6cbb26f --- /dev/null +++ b/xmake/modules/core/tools/filcc/features.lua @@ -0,0 +1,22 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @file features.lua +-- + +-- imports +inherit("core.tools.clang.features") + diff --git a/xmake/modules/core/tools/filcc/has_flags.lua b/xmake/modules/core/tools/filcc/has_flags.lua new file mode 100644 index 000000000..d96924ab9 --- /dev/null +++ b/xmake/modules/core/tools/filcc/has_flags.lua @@ -0,0 +1,22 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @file has_flags.lua +-- + +-- imports +inherit("core.tools.clang.has_flags") + diff --git a/xmake/modules/core/tools/filxx/features.lua b/xmake/modules/core/tools/filxx/features.lua new file mode 100644 index 000000000..9b6cbb26f --- /dev/null +++ b/xmake/modules/core/tools/filxx/features.lua @@ -0,0 +1,22 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @file features.lua +-- + +-- imports +inherit("core.tools.clang.features") + diff --git a/xmake/modules/core/tools/filxx/has_flags.lua b/xmake/modules/core/tools/filxx/has_flags.lua new file mode 100644 index 000000000..d96924ab9 --- /dev/null +++ b/xmake/modules/core/tools/filxx/has_flags.lua @@ -0,0 +1,22 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @file has_flags.lua +-- + +-- imports +inherit("core.tools.clang.has_flags") + diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 3bd9aefef..32f2960f9 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -971,10 +971,14 @@ function compargv(self, sourcefile, objectfile, flags, opt) opt = opt or {} -- is precompiled header or module files? remove the force includes. + -- @see https://github.com/xmake-io/xmake/issues/7560 local extension = path.extension(sourcefile) if toolchain_utils.is_cxx_headerext(extension) then flags = _translate_flags_for_pch(self, flags) - elseif support.has_module_extension(sourcefile, {extension = extension}) then + elseif support.has_module_extension(sourcefile, {extension = extension}) + or (opt.target and opt.target:type() == "target" + and support.contains_modules(opt.target) + and support.is_stdmodule_file(opt.target, sourcefile)) then flags = _translate_flags_for_mpp(self, flags) end diff --git a/xmake/rules/c++/modules/support.lua b/xmake/rules/c++/modules/support.lua index 1dd7625bb..126e25c61 100644 --- a/xmake/rules/c++/modules/support.lua +++ b/xmake/rules/c++/modules/support.lua @@ -201,6 +201,22 @@ function has_module_extension(sourcefile, opt) return modulexts:has(extension:lower()) end +-- is std module file? +-- e.g. libstdc++'s bits/std.cc and bits/std.compat.cc, which use the .cc extension +-- and therefore are not detected by has_module_extension. +-- @see https://github.com/xmake-io/xmake/issues/4051 +-- @see https://github.com/xmake-io/xmake/issues/7560 +function is_stdmodule_file(target, sourcefile) + if not target or not target.policy then + return false + end + if not target:policy("build.c++.modules.std") then + return false + end + local _, stdmodules_set = get_stdmodules(target) + return stdmodules_set and stdmodules_set:has(sourcefile) or false +end + -- this target contains module files? function contains_modules(target) -- we can not use `"c++.build.modules.builder"`, because it contains sourcekind/cxx. |
