-assert=
C ObjC C++ ObjC++ Joined Alias(A) MissingArgError(assertion missing after %qs)
+-compile-std-module
+C++ ObjC++ Driver
+--compile-std-module Compile module units for <bits/stdc++.h>, std, and std.compat.
+
-comments
C ObjC C++ ObjC++ Alias(C)
/* By default, we don't add -lstdc++exp. */
bool need_experimental = false;
+ /* Whether to also compile module std. */
+ bool std_module = false;
+
/* True if we saw -static. */
int static_link = 0;
which_library = (stdcxxlib_kind) decoded_options[i].value;
break;
+ case OPT__compile_std_module:
+ std_module = true;
+ break;
+
case OPT_SPECIAL_input_file:
{
int len;
/* Add one for shared_libgcc or extra static library. */
num_args = (argc + added + need_math + need_experimental
+ + (std_module * 5)
+ (library > 0) * 4 + 1);
/* For libc++, on most platforms, the ABI library (usually called libc++abi)
is provided as a separate DSO, which we must also append.
saw_libc = &decoded_options[i];
}
+ /* Insert --compile-std-module options before any -x or source files. */
+ size_t opt = decoded_options[i].opt_index;
+ if (std_module
+ && (opt == OPT__compile_std_module
+ || opt == OPT_SPECIAL_input_file
+ || opt == OPT_x))
+ {
+ generate_option (OPT_x, "c++-system-header", 1, CL_DRIVER,
+ &new_decoded_options[j++]);
+ generate_option_input_file ("bits/stdc++.h",
+ &new_decoded_options[j]);
+ /* Tell process_command that this file was added by the driver. */
+ new_decoded_options[j++].mask = CL_DRIVER;
+ generate_option (OPT_x, "c++-system-module", 1, CL_DRIVER,
+ &new_decoded_options[j++]);
+ generate_option_input_file ("bits/std.cc",
+ &new_decoded_options[j]);
+ new_decoded_options[j++].mask = CL_DRIVER;
+ generate_option_input_file ("bits/std.compat.cc",
+ &new_decoded_options[j]);
+ new_decoded_options[j++].mask = CL_DRIVER;
+ generate_option (OPT_x, "none", 1, CL_DRIVER,
+ &new_decoded_options[j++]);
+ new_decoded_options[j] = decoded_options[i];
+ std_module = false;
+ }
+ if (opt == OPT__compile_std_module)
+ --j;
+
/* Wrap foo.[chi] files in a language specification to
force the gcc compiler driver to run cc1plus on them. */
if (args[i] & LANGSPEC)
" %{!o*:--output-pch %w%i.gch}%W{o*:--output-pch %w%*}}}}%{!S:%V}}"
"}}}",
CPLUSPLUS_CPP_SPEC, 0, 0},
+ /* Just for implementing --compile-std-module. */
+ {"@c++-system-module",
+ "%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)"
+ " -fsearch-include-path=system}"
+ "%{!E:%{!M:%{!MM:"
+ " %{save-temps*|no-integrated-cpp:cc1plus -E"
+ " -fsearch-include-path=system"
+ " %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}"
+ " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed"
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)"
+ " -fsearch-include-path=system}}"
+ " %(cc1_options) %2"
+ " %{!fsyntax-only:"
+ " %{fmodule-only:%{!S:-o %g.s%V}}"
+ " %{!fmodule-only:%(invoke_as)}}"
+ "}}}",
+ CPLUSPLUS_CPP_SPEC, 0, 0},
{"@c++",
"%{E|M|MM:cc1plus -E %(cpp_options) %2 %(cpp_debug_options)}"
"%{!E:%{!M:%{!MM:"
@table @gcctabopt
+@opindex compile-std-module
+@item --compile-std-module
+Build the compiled module interfaces (@pxref{C++ Modules}) for the
+@samp{<bits/stdc++.h>} header unit and the @samp{std} and
+@samp{std.compat} modules before compiling any source files explicitly
+specified on the command line. This is intended to be useful for
+building simple programs that use @samp{import std;} with a single
+command.
+
@opindex fabi-version
@item -fabi-version=@var{n}
Use version @var{n} of the C++ ABI@. The default is version 0.
struct compiler *incompiler;
bool compiled;
bool preprocessed;
+ bool artificial;
};
/* Also a vector of input files specified. */
infiles. */
static void
-add_infile (const char *name, const char *language)
+add_infile (const char *name, const char *language, bool art = false)
{
alloc_infile ();
infiles[n_infiles].name = name;
+ infiles[n_infiles].artificial = art;
infiles[n_infiles++].language = language;
}
#ifdef HAVE_TARGET_OBJECT_SUFFIX
arg = convert_filename (arg, 0, access (arg, F_OK));
#endif
- add_infile (arg, spec_lang);
+ add_infile (arg, spec_lang,
+ decoded_options[j].mask == CL_DRIVER);
continue;
}
if (lang_n_infiles > 0 && compiler != input_file_compiler
&& infiles[i].language && infiles[i].language[0] != '*')
infiles[i].incompiler = compiler;
+ else if (infiles[i].artificial)
+ /* Leave lang_n_infiles alone so files added by the driver don't
+ interfere with -c -o. */
+ infiles[i].incompiler = compiler;
else if (compiler)
{
lang_n_infiles++;
--- /dev/null
+// { dg-additional-options "-fmodules --compile-std-module -g -O" }
+// { dg-do compile { target c++20 } }
+
+import <bits/stdc++.h>;
+import std;
+import std.compat;
+
+void f()
+{
+ std::string s;
+}
set extra_tool_flags {}
if { [llength $option_list]
- && [string match "*xtreme*" $src] } {
+ && ( [string match "*xtreme*" $src]
+ || [string match "*compile-std*" $src] ) } {
# Only run the xtreme tests once.
set option_list [lrange [lsort $option_list] end end]
}