@@ -1292,18 +1292,28 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1292
1292
// required by sourcekitd.
1293
1293
subClangImporterOpts.DetailedPreprocessingRecord =
1294
1294
clangImporterOpts.DetailedPreprocessingRecord ;
1295
+
1295
1296
// We need to add these extra clang flags because explict module building
1296
1297
// related flags are all there: -fno-implicit-modules, -fmodule-map-file=,
1297
1298
// and -fmodule-file=.
1298
1299
// If we don't add these flags, the interface will be built with implicit
1299
1300
// PCMs.
1300
- subClangImporterOpts.ExtraArgs = clangImporterOpts.ExtraArgs ;
1301
- for (auto arg: subClangImporterOpts.ExtraArgs ) {
1302
- GenericArgs.push_back (" -Xcc" );
1303
- GenericArgs.push_back (ArgSaver.save (arg));
1301
+ // FIXME: With Implicit Module Builds, if sub-invocations inherit `-fmodule-map-file=` options,
1302
+ // those modulemaps become File dependencies of all downstream PCMs and their depending Swift
1303
+ // modules, triggering unnecessary re-builds. We work around this by only inheriting these options
1304
+ // when building with explicit modules. While this problem will not manifest with Explicit Modules
1305
+ // (which do not use the ClangImporter to build PCMs), we may still need a better way to
1306
+ // decide which options must be inherited here.
1307
+ if (LoaderOpts.disableImplicitSwiftModule ) {
1308
+ subClangImporterOpts.ExtraArgs = clangImporterOpts.ExtraArgs ;
1309
+ for (auto arg : subClangImporterOpts.ExtraArgs ) {
1310
+ GenericArgs.push_back (" -Xcc" );
1311
+ GenericArgs.push_back (ArgSaver.save (arg));
1312
+ }
1304
1313
}
1305
1314
1306
- // Tell the genericSubInvocation to serialize dependency hashes if asked to do so.
1315
+ // Tell the genericSubInvocation to serialize dependency hashes if asked to do
1316
+ // so.
1307
1317
auto &frontendOpts = genericSubInvocation.getFrontendOptions ();
1308
1318
frontendOpts.SerializeModuleInterfaceDependencyHashes =
1309
1319
serializeDependencyHashes;
0 commit comments