On Sat, Nov 15, 2025 at 11:08:31PM +0530, Jason Merrill wrote:
> Tested x86_64-pc-linux-gnu.  Any opinions?  Bikeshedding of the flag name?
> 
> -- 8< --
> 
> For simple testcases that want to use the std module, it would be useful to
> have a reasonably short way to request building the binary module form
> before the testcase.  So with this patch users can write
> 
>   g++ -std=c++20 -fmodules --compile-std-module mytest.C
> 
> gcc/c-family/ChangeLog:
> 
>       * c.opt: Add --compile-std-module.
> 
> gcc/cp/ChangeLog:
> 
>       * lang-specs.h: Add @c++-system-module.
>       * g++spec.cc (lang_specific_driver): Handle --compile-std-module.
> 
> gcc/ChangeLog:
> 
>       * opts-common.cc (generate_canonical_option): Handle
>       OPT_SPECIAL_input_file.

If this would be solely for GCC testsuite and nothing else, my preference
would be to do this in DejaGNU with // { dg-compile-std-module
But if the intent is also users compiling simple C++ sources, then that
doesn't work.
I wonder if expansion of --compile-std-module into
-xc++-system-header bits/stdc++.h -xc++-system-module bits/std.cc 
-xc++-system-module bits/std.compat.cc -xnone
won't cause surprising result for users which are using -x <language>.
E.g. if their C++ source is *.c and they compile with
g++ -xc++ --compile-std-module foo.c
won't that compile it using cc1 because -xnone cancelled the
earlier language setting?
I.e. don't we need -xpush and -xpop or -xsave and -xrestore
which would save/restore existing -x <language> setting?

        Jakub

Reply via email to