@@ -4051,15 +4051,24 @@ static bool RenderModulesOptions(Compilation &C, const Driver &D,
40514051 // module fragment.
40524052 CmdArgs.push_back (" -fskip-odr-check-in-gmf" );
40534053
4054- if (!Args.hasArg (options::OPT_fno_modules_reduced_bmi) &&
4055- (Input.getType () == driver::types::TY_CXXModule ||
4056- Input.getType () == driver::types::TY_PP_CXXModule) &&
4057- !Args.hasArg (options::OPT__precompile)) {
4058- CmdArgs.push_back (" -fmodules-reduced-bmi" );
4054+ if (Input.getType () == driver::types::TY_CXXModule ||
4055+ Input.getType () == driver::types::TY_PP_CXXModule) {
4056+ if (!Args.hasArg (options::OPT_fno_modules_reduced_bmi))
4057+ CmdArgs.push_back (" -fmodules-reduced-bmi" );
40594058
40604059 if (Args.hasArg (options::OPT_fmodule_output_EQ))
40614060 Args.AddLastArg (CmdArgs, options::OPT_fmodule_output_EQ);
4062- else
4061+ else if (!Args.hasArg (options::OPT__precompile) ||
4062+ Args.hasArg (options::OPT_fmodule_output))
4063+ // If --precompile is specified, we will always generate a module file if
4064+ // we're compiling an importable module unit. This is fine even if the
4065+ // compilation process won't reach the point of generating the module file
4066+ // (e.g., in the preprocessing mode), since the attached flag
4067+ // '-fmodule-output' is useless.
4068+ //
4069+ // But if '--precompile' is specified, it might be annoying to always
4070+ // generate the module file as '--precompile' will generate the module
4071+ // file anyway.
40634072 CmdArgs.push_back (Args.MakeArgString (
40644073 " -fmodule-output=" +
40654074 getCXX20NamedModuleOutputPath (Args, Input.getBaseInput ())));
0 commit comments