On 10/15/24 10:57 AM, Jakub Jelinek wrote:
On Fri, Oct 11, 2024 at 10:41:36PM -0400, Jason Merrill wrote:
The intent is that C++20 module header units obsolete PCH; they serve the
same function and are more flexible (you can import multiple header units).
Though, simple use of -std=c++20 or -std=c++23 doesn't imply one is using
modules.
Unfortunately there is no special driver option for PCH header writing,
but until now one had to use explicit -fmodules to disable the PCH header
writing and produce header unit.
Can't we keep it that way, i.e. only disable PCH with explicit -fmodules,
for implicit ones simply write both PCH and module header unit?
Then users can decide when using it what they actually use, either
they import a module header unit, or they include header and get PCH.
But #include works transparently with header units just like PCH. Given
a header.hh and user.cc that includes it,
gcc -c header.hh
gcc -c user.cc
is effectively the same regardless of whether a PCH or header unit is
produced and read. There's no necessary difference at the source code
level; the only difference currently is the presence of a -fmodule* flag
on the command line.
There is a difference in where the compiled form of the header is output
and found (on the include path vs. in gcm.cache). PCH also supports
having a directory of possible PCH to try; I don't know how important
that is to any actual users of PCH.
But yeah, this is probably premature, just curious about more usage
feedback.
Jason