On Tue, Nov 18, 2025 at 10:48:12PM +0530, Jason Merrill wrote:
> From c7c1f32a477c42de3fd9308e90d09b6a617893df Mon Sep 17 00:00:00 2001
> From: Jason Merrill <[email protected]>
> Date: Tue, 11 Nov 2025 15:58:01 +0530
> Subject: [PATCH] driver/c++: add --compile-std-module
> To: [email protected]
> 
> 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
> 
> I expect this to be particularly useful on godbolt.org, where currently
> building a modules testcase requires messing with cmake.  One complication
> there is that just adding std.cc to the command line arguments hits the
> "cannot specify -o with -S with multiple files" error, so I avoid counting
> these added inputs as "multiple files"; in that situation each compile will
> output to the same target file, with the user-specified input last so it's
> the one that actually ends up in the target after the command completes.

LGTM, but please give Joseph a chance to chime in.

> 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:
> 
>       * doc/invoke.texi: Document --compile-std-module.
>       * gcc.cc (struct infile): Add artificial field.
>       (add_infile): Set it.
>       (driver::prepare_infiles): Check it.

        Jakub

Reply via email to