@@ -4051,15 +4051,24 @@ static bool RenderModulesOptions(Compilation &C, const Driver &D,
4051
4051
// module fragment.
4052
4052
CmdArgs.push_back (" -fskip-odr-check-in-gmf" );
4053
4053
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" );
4059
4058
4060
4059
if (Args.hasArg (options::OPT_fmodule_output_EQ))
4061
4060
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.
4063
4072
CmdArgs.push_back (Args.MakeArgString (
4064
4073
" -fmodule-output=" +
4065
4074
getCXX20NamedModuleOutputPath (Args, Input.getBaseInput ())));
0 commit comments