c++/objective-c++; Do not claim feature(modules), it is clang-specific.

Message ID 20260804085640.90357-1-iain@sandoe.co.uk
State New
Headers
Series c++/objective-c++; Do not claim feature(modules), it is clang-specific. |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed

Commit Message

Iain Sandoe Aug. 4, 2026, 8:56 a.m. UTC
  Tested on x86_64 darwin24 where we now correctly create the std module
sources and gcms.  OK for trunk and relevant backports? thanks,
Iain

--- 8< ---

It appears that we misinterpreted the modules feature and that it is intended
to signal that the compiler supports "clang modules".  These are a similar
approach to PCH and tightly coupled to clang AST - so not something that we
are realistically likely to implement.

Unfortunately, the macOS SDKs use this feature test to decide on some
header declaration ordering where it needs to change for clang modules.

This causes a fail to build the std. module sources on macOS meaning that we
get an empty std.cc. Our intention should be parity with/without -fmodules.

The solution is not to claim feature(modules) - C++20 modules are gated on
__cpp_module and so do not need it.

gcc/cp/ChangeLog:

	* cp-objcp-common.cc: Remove claim to support clang modules.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/cp/cp-objcp-common.cc | 1 -
 1 file changed, 1 deletion(-)
  

Comments

Jason Merrill Aug. 4, 2026, 4:21 p.m. UTC | #1
On 8/4/26 4:56 AM, Iain Sandoe wrote:
> Tested on x86_64 darwin24 where we now correctly create the std module
> sources and gcms.  OK for trunk and relevant backports? thanks,

OK.
> --- 8< ---
> 
> It appears that we misinterpreted the modules feature and that it is intended
> to signal that the compiler supports "clang modules".  These are a similar
> approach to PCH and tightly coupled to clang AST - so not something that we
> are realistically likely to implement.
> 
> Unfortunately, the macOS SDKs use this feature test to decide on some
> header declaration ordering where it needs to change for clang modules.
> 
> This causes a fail to build the std. module sources on macOS meaning that we
> get an empty std.cc. Our intention should be parity with/without -fmodules.
> 
> The solution is not to claim feature(modules) - C++20 modules are gated on
> __cpp_module and so do not need it.
> 
> gcc/cp/ChangeLog:
> 
> 	* cp-objcp-common.cc: Remove claim to support clang modules.
> 
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>   gcc/cp/cp-objcp-common.cc | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
> index 0a67aa8ce14..8c9930bb2f3 100644
> --- a/gcc/cp/cp-objcp-common.cc
> +++ b/gcc/cp/cp-objcp-common.cc
> @@ -148,7 +148,6 @@ static constexpr cp_feature_info cp_feature_table[] =
>     { "cxx_relaxed_constexpr", cxx14 },
>     { "cxx_return_type_deduction", cxx14 },
>     { "cxx_variable_templates", cxx14 },
> -  { "modules", &flag_modules },
>   };
>   
>   /* Register C++ language features for __has_{feature,extension}.  */
  

Patch

diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
index 0a67aa8ce14..8c9930bb2f3 100644
--- a/gcc/cp/cp-objcp-common.cc
+++ b/gcc/cp/cp-objcp-common.cc
@@ -148,7 +148,6 @@  static constexpr cp_feature_info cp_feature_table[] =
   { "cxx_relaxed_constexpr", cxx14 },
   { "cxx_return_type_deduction", cxx14 },
   { "cxx_variable_templates", cxx14 },
-  { "modules", &flag_modules },
 };
 
 /* Register C++ language features for __has_{feature,extension}.  */