Skip to content

Commit 391a18d

Browse files
authored
Merge pull request #84443 from artemcm/RestrictEmbeddedToBinarySwift
[Dependency Scanning] Avoid querying Swift Overlay for underlying module
2 parents 0737723 + e9a7519 commit 391a18d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

lib/DependencyScan/ModuleDependencyScanner.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
14561456

14571457
// A scanning task to query a Swift module by-name. If the module already
14581458
// exists in the cache, do nothing and return.
1459-
auto scanForSwiftDependency = [this, &cache, &lookupResultLock,
1459+
auto scanForSwiftDependency = [this, &moduleID, &cache, &lookupResultLock,
14601460
&swiftOverlayLookupResult](
14611461
Identifier moduleIdentifier) {
14621462
auto moduleName = moduleIdentifier.str();
@@ -1467,6 +1467,13 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
14671467
return;
14681468
}
14691469

1470+
// Avoid Swift overlay lookup for the underlying clang module of a known
1471+
// Swift module. i.e. When computing set of Swift Overlay dependencies
1472+
// for module 'A', which depends on a Clang module 'A', ensure we don't
1473+
// lookup Swift module 'A' itself here.
1474+
if (moduleName == moduleID.ModuleName)
1475+
return;
1476+
14701477
auto moduleDependencies = withDependencyScanningWorker(
14711478
[moduleIdentifier](ModuleDependencyScanningWorker *ScanningWorker) {
14721479
return ScanningWorker->scanFilesystemForSwiftModuleDependency(

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4171,6 +4171,7 @@ bool CompilerInvocation::parseArgs(
41714171
IRGenOpts.ReflectionMetadata = ReflectionMetadataMode::None;
41724172
IRGenOpts.EnableReflectionNames = false;
41734173
FrontendOpts.DisableBuildingInterface = true;
4174+
SearchPathOpts.ModuleLoadMode = ModuleLoadingMode::OnlySerialized;
41744175
TypeCheckerOpts.SkipFunctionBodies = FunctionBodySkipping::None;
41754176
SILOpts.SkipFunctionBodies = FunctionBodySkipping::None;
41764177
SILOpts.CMOMode = CrossModuleOptimizationMode::Everything;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// REQUIRES: swift_feature_Embedded
2+
// RUN: %empty-directory(%t)
3+
// RUN: split-file %s %t
4+
5+
// RUN: %target-swift-frontend -emit-module %t/Foo.swift -emit-module-path %t/Foo.swiftmodule/%target-swiftmodule-name -module-name Foo -emit-module-interface-path %t/Foo.swiftmodule/%target-swiftinterface-name -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib -enable-library-evolution
6+
7+
// RUN: %target-swift-frontend -scan-dependencies \
8+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib \
9+
// RUN: %t/main.swift -I %t -enable-experimental-feature Embedded -o - | %FileCheck %s --check-prefix=SERIALIZED
10+
11+
// SERIALIZED: "swiftPrebuiltExternal": "Foo"
12+
13+
//--- main.swift
14+
import Foo
15+
16+
//--- Foo.swift
17+
public func foo() {}
18+

0 commit comments

Comments
 (0)