Skip to content

Commit 94ca17e

Browse files
authored
Merge pull request #38684 from nkcsgexi/81177968
DependenciesScanner: include -sdk in Swift module building command
2 parents 7bee60e + 2132a90 commit 94ca17e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,13 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
12901290
genericSubInvocation.setImportSearchPaths(SearchPathOpts.ImportSearchPaths);
12911291
genericSubInvocation.setFrameworkSearchPaths(SearchPathOpts.FrameworkSearchPaths);
12921292
if (!SearchPathOpts.SDKPath.empty()) {
1293+
// Add -sdk arguments to the module building commands.
1294+
// Module building commands need this because dependencies sometimes use
1295+
// sdk-relative paths (prebuilt modules for example). Without -sdk, the command
1296+
// will not be able to local these dependencies, leading to unnecessary
1297+
// building from textual interfaces.
1298+
GenericArgs.push_back("-sdk");
1299+
GenericArgs.push_back(ArgSaver.save(SearchPathOpts.SDKPath));
12931300
genericSubInvocation.setSDKPath(SearchPathOpts.SDKPath);
12941301
}
12951302

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -sdk %t/mysecretsdk.sdk
4+
5+
// Check the contents of the JSON output
6+
// RUN: %FileCheck %s < %t/deps.json
7+
8+
func foo() { print(1) }
9+
10+
// CHECK: "-sdk",
11+
// CHECK-NEXT: mysecretsdk.sdk

test/ScanDependencies/module_deps.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ import SubE
213213
/// --------Clang module SwiftShims
214214
// CHECK-LABEL: "modulePath": "SwiftShims.pcm",
215215

216-
// CHECK-NO-SEARCH-PATHS-NOT: "-sdk"
217216
// CHECK-NO-SEARCH-PATHS-NOT: "-prebuilt-module-cache-path"
218217

219218
// Check make-style dependencies

0 commit comments

Comments
 (0)