@@ -154,6 +154,20 @@ void ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
154154 }
155155}
156156
157+ void dependencies::removeUnnecessaryDependencies (CompilerInvocation &CI,
158+ bool ForModuleBuild) {
159+ if (CI.getFrontendOpts ().ProgramAction == frontend::GeneratePCH ||
160+ (ForModuleBuild && !CI.getLangOpts ().ModulesCodegen )) {
161+ CI.getCodeGenOpts ().DebugCompilationDir .clear ();
162+ CI.getCodeGenOpts ().CoverageCompilationDir .clear ();
163+ CI.getCodeGenOpts ().CoverageDataFile .clear ();
164+ CI.getCodeGenOpts ().CoverageNotesFile .clear ();
165+ CI.getCodeGenOpts ().ProfileInstrumentUsePath .clear ();
166+ CI.getCodeGenOpts ().SampleProfileFile .clear ();
167+ CI.getCodeGenOpts ().ProfileRemappingFile .clear ();
168+ }
169+ }
170+
157171static CowCompilerInvocation
158172makeCommonInvocationForModuleBuild (CompilerInvocation CI) {
159173 CI.resetNonModularOptions ();
@@ -170,15 +184,8 @@ makeCommonInvocationForModuleBuild(CompilerInvocation CI) {
170184 // TODO: Figure out better way to set options to their default value.
171185 CI.getCodeGenOpts ().MainFileName .clear ();
172186 CI.getCodeGenOpts ().DwarfDebugFlags .clear ();
173- if (!CI.getLangOpts ().ModulesCodegen ) {
174- CI.getCodeGenOpts ().DebugCompilationDir .clear ();
175- CI.getCodeGenOpts ().CoverageCompilationDir .clear ();
176- CI.getCodeGenOpts ().CoverageDataFile .clear ();
177- CI.getCodeGenOpts ().CoverageNotesFile .clear ();
178- CI.getCodeGenOpts ().ProfileInstrumentUsePath .clear ();
179- CI.getCodeGenOpts ().SampleProfileFile .clear ();
180- CI.getCodeGenOpts ().ProfileRemappingFile .clear ();
181- }
187+
188+ removeUnnecessaryDependencies (CI, /* ForModuleBuild=*/ true );
182189
183190 // Map output paths that affect behaviour to "-" so their existence is in the
184191 // context hash. The final path will be computed in addOutputPaths.
0 commit comments