Skip to content

DependenciesScanner: include -sdk in Swift module building command #38684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,13 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
genericSubInvocation.setImportSearchPaths(SearchPathOpts.ImportSearchPaths);
genericSubInvocation.setFrameworkSearchPaths(SearchPathOpts.FrameworkSearchPaths);
if (!SearchPathOpts.SDKPath.empty()) {
// Add -sdk arguments to the module building commands.
// Module building commands need this 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
// building from textual interfaces.
GenericArgs.push_back("-sdk");
GenericArgs.push_back(ArgSaver.save(SearchPathOpts.SDKPath));
genericSubInvocation.setSDKPath(SearchPathOpts.SDKPath);
}

Expand Down
11 changes: 11 additions & 0 deletions test/ScanDependencies/include-sdk-in-command.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -sdk %t/mysecretsdk.sdk

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json

func foo() { print(1) }

// CHECK: "-sdk",
// CHECK-NEXT: mysecretsdk.sdk
1 change: 0 additions & 1 deletion test/ScanDependencies/module_deps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ import SubE
/// --------Clang module SwiftShims
// CHECK-LABEL: "modulePath": "SwiftShims.pcm",

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

// Check make-style dependencies
Expand Down