Skip to content

Commit 957f49a

Browse files
committed
[Dependency Scanning] Do not process transitive '@_implementationOnly' dependencies of binary Swift modules
These modules are not guaranteed to be found, which is okay, as compilation is meant to be possible in their absense since their contents are not used in the public API of the module which imports them as implementation-only. Resolves rdar://103031296
1 parent c707643 commit 957f49a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ llvm::ErrorOr<ModuleDependencyInfo> SerializedModuleLoaderBase::scanModuleFile(
420420
if (dependency.isHeader())
421421
continue;
422422

423+
// Transitive @_implementationOnly dependencies of
424+
// binary modules are not required to be imported during normal builds
425+
// TODO: This is worth revisiting for debugger purposes
426+
if (dependency.isImplementationOnly())
427+
continue;
428+
423429
// Find the top-level module name.
424430
auto modulePathStr = dependency.getPrettyPrintedPath();
425431
StringRef moduleName = modulePathStr;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/clang-module-cache
3+
// RUN: mkdir -p %t/Frameworks
4+
// RUN: mkdir -p %t/Frameworks/Foo.framework/
5+
// RUN: mkdir -p %t/Frameworks/Foo.framework/Modules
6+
// RUN: mkdir -p %t/Frameworks/Foo.framework/Modules/Foo.swiftmodule
7+
8+
// Build a dependency into a binary module with an @_implementationOnly dependency on `E`
9+
// RUN: echo "@_implementationOnly import E;public func foo() {}" >> %t/foo.swift
10+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Frameworks/Foo.framework/Modules/Foo.swiftmodule/%target-cpu.swiftmodule -module-cache-path %t.module-cache %t/foo.swift -module-name Foo -I %S/Inputs/Swift
11+
12+
// Run the scan
13+
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -F %t/Frameworks/ -sdk %t
14+
// RUN: %FileCheck %s < %t/deps.json
15+
16+
import Foo
17+
18+
// CHECK-NOT: "swift": "E"

0 commit comments

Comments
 (0)