Skip to content

Commit 8dbbc80

Browse files
committed
[Dependency Scanning] Inherit target SDK name and version for textual interface build recipes
Otherwise they get built with an empty SDK name string and we do not get the benefit of the SDK name compatibility check in case they are loading modules from an incompatible SDK Resolves rdar://135972810
1 parent e5abfcb commit 8dbbc80

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,19 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
16701670
GenericArgs.push_back(triple);
16711671
}
16721672

1673+
// Inherit the target SDK name and version
1674+
if (!LangOpts.SDKName.empty()) {
1675+
genericSubInvocation.getLangOptions().SDKName = LangOpts.SDKName;
1676+
GenericArgs.push_back("-target-sdk-name");
1677+
GenericArgs.push_back(ArgSaver.save(LangOpts.SDKName));
1678+
}
1679+
if (LangOpts.SDKVersion.has_value()) {
1680+
genericSubInvocation.getLangOptions().SDKVersion = LangOpts.SDKVersion;
1681+
GenericArgs.push_back("-target-sdk-version");
1682+
GenericArgs.push_back(ArgSaver.save(LangOpts.SDKVersion.value()
1683+
.getAsString()));
1684+
}
1685+
16731686
// Inherit the Swift language version
16741687
genericSubInvocation.getLangOptions().EffectiveLanguageVersion =
16751688
LangOpts.EffectiveLanguageVersion;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface %s -o %t/deps.json -target-sdk-version 15.0 -target-sdk-name macosx15.0.test_name
3+
4+
// Check the contents of the JSON output
5+
// RUN: %validate-json %t/deps.json | %FileCheck %s
6+
7+
func foo() { print(1) }
8+
9+
// CHECK: "-target-sdk-name",
10+
// CHECK-NEXT: "macosx15.0.test_name"
11+
// CHECK: "-target-sdk-version",
12+
// CHECK-NEXT: "15.0"

0 commit comments

Comments
 (0)