@@ -309,36 +309,41 @@ class ExplicitModuleDependencyResolver {
309309 llvm::Error handleSwiftInterfaceModuleDependency (
310310 ModuleDependencyID depModuleID,
311311 const SwiftInterfaceModuleDependenciesStorage &interfaceDepDetails) {
312- auto &path = interfaceDepDetails.moduleCacheKey .empty ()
313- ? interfaceDepDetails.moduleOutputPath
314- : interfaceDepDetails.moduleCacheKey ;
315- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
316- path);
312+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
313+ auto &path = interfaceDepDetails.moduleCacheKey .empty ()
314+ ? interfaceDepDetails.moduleOutputPath
315+ : interfaceDepDetails.moduleCacheKey ;
316+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
317+ " =" + path);
318+ }
317319 addMacroDependencies (depModuleID, interfaceDepDetails);
318320 return llvm::Error::success ();
319321 }
320322
321323 llvm::Error handleSwiftBinaryModuleDependency (
322324 ModuleDependencyID depModuleID,
323325 const SwiftBinaryModuleDependencyStorage &binaryDepDetails) {
324- auto &path = binaryDepDetails.moduleCacheKey .empty ()
325- ? binaryDepDetails.compiledModulePath
326- : binaryDepDetails.moduleCacheKey ;
327- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
328- path);
329- // If this binary module was built with a header, the header's module
330- // dependencies must also specify a .modulemap to the compilation, in
331- // order to resolve the header's own header include directives.
332- for (const auto &bridgingHeaderDepID :
333- binaryDepDetails.headerModuleDependencies ) {
334- auto optionalBridgingHeaderDepModuleInfo = cache.findKnownDependency (
335- bridgingHeaderDepID);
336- const auto bridgingHeaderDepModuleDetails =
337- optionalBridgingHeaderDepModuleInfo.getAsClangModule ();
338- commandline.push_back (" -Xcc" );
339- commandline.push_back (" -fmodule-map-file=" +
340- cache.getScanService ().remapPath (
341- bridgingHeaderDepModuleDetails->moduleMapFile ));
326+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
327+ auto &path = binaryDepDetails.moduleCacheKey .empty ()
328+ ? binaryDepDetails.compiledModulePath
329+ : binaryDepDetails.moduleCacheKey ;
330+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
331+ " =" + path);
332+ // If this binary module was built with a header, the header's module
333+ // dependencies must also specify a .modulemap to the compilation, in
334+ // order to resolve the header's own header include directives.
335+ for (const auto &bridgingHeaderDepID :
336+ binaryDepDetails.headerModuleDependencies ) {
337+ auto optionalBridgingHeaderDepModuleInfo =
338+ cache.findKnownDependency (bridgingHeaderDepID);
339+ const auto bridgingHeaderDepModuleDetails =
340+ optionalBridgingHeaderDepModuleInfo.getAsClangModule ();
341+ commandline.push_back (" -Xcc" );
342+ commandline.push_back (
343+ " -fmodule-map-file=" +
344+ cache.getScanService ().remapPath (
345+ bridgingHeaderDepModuleDetails->moduleMapFile ));
346+ }
342347 }
343348 addMacroDependencies (depModuleID, binaryDepDetails);
344349 return llvm::Error::success ();
@@ -347,26 +352,29 @@ class ExplicitModuleDependencyResolver {
347352 llvm::Error handleSwiftPlaceholderModuleDependency (
348353 ModuleDependencyID depModuleID,
349354 const SwiftPlaceholderModuleDependencyStorage &placeholderDetails) {
350- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
351- placeholderDetails.compiledModulePath );
355+ if (!resolvingDepInfo.isSwiftSourceModule ())
356+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
357+ " =" + placeholderDetails.compiledModulePath );
352358 return llvm::Error::success ();
353359 }
354360
355361 llvm::Error handleClangModuleDependency (
356362 ModuleDependencyID depModuleID,
357363 const ClangModuleDependencyStorage &clangDepDetails) {
358- if (!resolvingDepInfo.isClangModule ()) {
359- commandline.push_back (" -Xcc" );
360- commandline.push_back (" -fmodule-file=" + depModuleID.ModuleName + " =" +
361- clangDepDetails.mappedPCMPath );
362- }
363- if (!clangDepDetails.moduleCacheKey .empty ()) {
364- commandline.push_back (" -Xcc" );
365- commandline.push_back (" -fmodule-file-cache-key" );
366- commandline.push_back (" -Xcc" );
367- commandline.push_back (clangDepDetails.mappedPCMPath );
368- commandline.push_back (" -Xcc" );
369- commandline.push_back (clangDepDetails.moduleCacheKey );
364+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
365+ if (!resolvingDepInfo.isClangModule ()) {
366+ commandline.push_back (" -Xcc" );
367+ commandline.push_back (" -fmodule-file=" + depModuleID.ModuleName + " =" +
368+ clangDepDetails.mappedPCMPath );
369+ }
370+ if (!clangDepDetails.moduleCacheKey .empty ()) {
371+ commandline.push_back (" -Xcc" );
372+ commandline.push_back (" -fmodule-file-cache-key" );
373+ commandline.push_back (" -Xcc" );
374+ commandline.push_back (clangDepDetails.mappedPCMPath );
375+ commandline.push_back (" -Xcc" );
376+ commandline.push_back (clangDepDetails.moduleCacheKey );
377+ }
370378 }
371379
372380 // Collect CAS deppendencies from clang modules.
@@ -1304,7 +1312,7 @@ bool swift::dependencies::scanDependencies(CompilerInstance &instance) {
13041312 *service, instance.getMainModule ()->getNameStr ().str (),
13051313 instance.getInvocation ().getFrontendOptions ().ExplicitModulesOutputPath ,
13061314 instance.getInvocation ().getModuleScanningHash ());
1307-
1315+
13081316 if (opts.ReuseDependencyScannerCache )
13091317 deserializeDependencyCache (instance, cache);
13101318
@@ -1391,7 +1399,7 @@ bool swift::dependencies::batchScanDependencies(
13911399 return true ;
13921400
13931401 auto batchScanResults = performBatchModuleScan (
1394- instance, /* DependencyScanDiagnosticCollector*/ nullptr ,
1402+ instance, /* DependencyScanDiagnosticCollector*/ nullptr ,
13951403 cache, /* versionedPCMInstanceCache*/ nullptr , saver,
13961404 *batchInput);
13971405
@@ -1652,7 +1660,7 @@ swift::dependencies::performBatchModuleScan(
16521660 }
16531661 allDependencies = scanner.performDependencyScan (moduleID, cache);
16541662 }
1655-
1663+
16561664 batchScanResult.push_back (
16571665 generateFullDependencyGraph (instance, diagnosticCollector, cache,
16581666 allDependencies));
0 commit comments