Skip to content

Commit 2d89d9f

Browse files
nkcsgexiartemcm
authored andcommitted
DependenciesScanner: include -sdk in Swift module building command
Swift module building commands need -sdk because dependencies sometimes use sdk-relative paths (prebuilt modules for example). Without -sdk, the command will not be able to local these dependencies, leading to unnecessary rebuilding from textual interfaces. rdar://81177968
1 parent 3e8fea9 commit 2d89d9f

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
@@ -1153,6 +1153,13 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
11531153
genericSubInvocation.setImportSearchPaths(SearchPathOpts.ImportSearchPaths);
11541154
genericSubInvocation.setFrameworkSearchPaths(SearchPathOpts.FrameworkSearchPaths);
11551155
if (!SearchPathOpts.SDKPath.empty()) {
1156+
// Add -sdk arguments to the module building commands.
1157+
// Module building commands need this because dependencies sometimes use
1158+
// sdk-relative paths (prebuilt modules for example). Without -sdk, the command
1159+
// will not be able to local these dependencies, leading to unnecessary
1160+
// building from textual interfaces.
1161+
GenericArgs.push_back("-sdk");
1162+
GenericArgs.push_back(ArgSaver.save(SearchPathOpts.SDKPath));
11561163
genericSubInvocation.setSDKPath(SearchPathOpts.SDKPath);
11571164
}
11581165

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)