On 11/17/25 2:35 PM, Jakub Jelinek wrote:
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.

Indeed, it's intended more for users.

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

Do people put other options between -x and their source files? I suppose we could insert the new options before any user-specified -x (or source file) rather than at the position of the ---compile-std-module.

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