Skip to content

Commit 6bdb193

Browse files
committed
[Dependency Scanning] Treat '-embed-tbd-for-module' modules as implicit import dependencies.
Otherwise the scanning action will not look for them as dependencies, and the compilation it is used to inform will not specify these moduels as explicit inpouts. Resolves rdar://104761392
1 parent c707643 commit 6bdb193

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,13 @@ identifyMainModuleDependencies(CompilerInstance &instance) {
11951195
mainDependencies.addModuleImport(mainModule->getName().str(),
11961196
&alreadyAddedModules);
11971197
}
1198+
1199+
// All modules specified with `-embed-tbd-for-module` are treated as implicit
1200+
// dependnecies for this compilation since they are not guaranteed to be impored
1201+
// in the source.
1202+
for (const auto &tbdSymbolModule : instance.getInvocation().getTBDGenOptions().embedSymbolsFromModules) {
1203+
mainDependencies.addModuleImport(tbdSymbolModule, &alreadyAddedModules);
1204+
}
11981205
}
11991206

12001207
return mainDependencies;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/clang-module-cache
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -swift-version 4 -embed-tbd-for-module E
5+
// RUN: %FileCheck %s < %t/deps.json
6+
7+
// CHECK: "mainModuleName": "deps"
8+
// CHECK-NEXT: "modules": [
9+
// CHECK-NEXT: {
10+
// CHECK-NEXT: "swift": "deps"
11+
// CHECK-NEXT: },
12+
// CHECK: "directDependencies": [
13+
14+
// Ensure there is a dependency on 'E' even though it is not explicitly imported
15+
// CHECK: "swift": "E"
16+

0 commit comments

Comments
 (0)