-
Notifications
You must be signed in to change notification settings - Fork 10.5k
ModuleInterface: Setup logic to load distributed swiftinterfaces over swiftmodules by default #71617
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
ModuleInterface: Setup logic to load distributed swiftinterfaces over swiftmodules by default #71617
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
test/ModuleInterface/prefer-swiftinterface-by-default.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/// The blocklist can enable loading distributed swiftinterfaces by default. | ||
|
||
// RUN: %empty-directory(%t) | ||
// RUN: split-file %s %t --leading-lines | ||
// REQUIRES: VENDOR=apple | ||
|
||
/// Setup the SDK and local modules. | ||
//// SDK module in S/L/F. | ||
// RUN: %target-swift-frontend -emit-module -module-name SDKModule %t/Empty.swift \ | ||
// RUN: -enable-library-evolution -swift-version 5 -parse-stdlib \ | ||
// RUN: -emit-module-path %t/sdk/System/Library/Frameworks/SDKModule.framework/Modules/SDKModule.swiftmodule/%target-swiftmodule-name \ | ||
// RUN: -emit-module-interface-path %t/sdk/System/Library/Frameworks/SDKModule.framework/Modules/SDKModule.swiftmodule/%target-swiftinterface-name | ||
// RUN: %target-swift-typecheck-module-from-interface(%t/sdk/System/Library/Frameworks/SDKModule.framework/Modules/SDKModule.swiftmodule/%target-swiftinterface-name) -module-name SDKModule | ||
|
||
//// SDK module not in S/L/F. | ||
// RUN: %target-swift-frontend -emit-module -module-name SDKModuleAtUnusualPath %t/Empty.swift \ | ||
// RUN: -enable-library-evolution -swift-version 5 -parse-stdlib \ | ||
// RUN: -emit-module-path %t/sdk/System/Library/OtherFrameworks/SDKModuleAtUnusualPath.framework/Modules/SDKModuleAtUnusualPath.swiftmodule/%target-swiftmodule-name \ | ||
// RUN: -emit-module-interface-path %t/sdk/System/Library/OtherFrameworks/SDKModuleAtUnusualPath.framework/Modules/SDKModuleAtUnusualPath.swiftmodule/%target-swiftinterface-name | ||
// RUN: %target-swift-typecheck-module-from-interface(%t/sdk/System/Library/OtherFrameworks/SDKModuleAtUnusualPath.framework/Modules/SDKModuleAtUnusualPath.swiftmodule/%target-swiftinterface-name) -module-name SDKModuleAtUnusualPath | ||
|
||
//// Local module. | ||
// RUN: %target-swift-frontend -emit-module -module-name LocalModule %t/Empty.swift \ | ||
// RUN: -enable-library-evolution -swift-version 5 -parse-stdlib \ | ||
// RUN: -emit-module-path %t/not_sdk/LocalModule.swiftmodule \ | ||
// RUN: -emit-module-interface-path %t/not_sdk/LocalModule.swiftinterface | ||
// RUN: %target-swift-typecheck-module-from-interface(%t/not_sdk/LocalModule.swiftinterface) -module-name LocalModule | ||
|
||
//// Host resource-dir module. | ||
// RUN: %target-swift-frontend -emit-module -module-name HostResourceDirModule %t/Empty.swift \ | ||
// RUN: -enable-library-evolution -swift-version 5 -parse-stdlib \ | ||
// RUN: -emit-module-path %t/res/host/HostResourceDirModule.swiftmodule \ | ||
// RUN: -emit-module-interface-path %t/res/host/HostResourceDirModule.swiftinterface | ||
// RUN: %target-swift-typecheck-module-from-interface(%t/res/host/HostResourceDirModule.swiftinterface) -module-name HostResourceDirModule | ||
|
||
//// Blocklisted module. | ||
// RUN: %target-swift-frontend -emit-module -module-name BlocklistedModule %t/Empty.swift \ | ||
// RUN: -enable-library-evolution -swift-version 5 -parse-stdlib \ | ||
// RUN: -emit-module-path %t/sdk/System/Library/Frameworks/BlocklistedModule.framework/Modules/BlocklistedModule.swiftmodule/%target-swiftmodule-name \ | ||
// RUN: -emit-module-interface-path %t/sdk/System/Library/Frameworks/BlocklistedModule.framework/Modules/BlocklistedModule.swiftmodule/%target-swiftinterface-name | ||
// RUN: %target-swift-typecheck-module-from-interface(%t/sdk/System/Library/Frameworks/BlocklistedModule.framework/Modules/BlocklistedModule.swiftmodule/%target-swiftinterface-name) -module-name BlocklistedModule | ||
|
||
/// Build a client preferring swiftinterfaces. | ||
// RUN: %target-swift-frontend -typecheck -module-name Main %t/Client_SwiftinterfacesByDefault.swift \ | ||
// RUN: -parse-stdlib -module-cache-path %t/cache \ | ||
// RUN: -blocklist-file %t/blocklistEnabled.yml \ | ||
// RUN: -sdk %t/sdk -I %t/not_sdk -resource-dir %t/res -I %t/res/host/ \ | ||
// RUN: -F %t/sdk/System/Library/OtherFrameworks/ \ | ||
// RUN: -Rmodule-interface-rebuild -verify | ||
|
||
/// Build a client preferring swiftmodules. | ||
// RUN: %empty-directory(%t/cache) | ||
// RUN: %target-swift-frontend -typecheck -module-name Main %t/Client_SwiftmodulesByDefault.swift \ | ||
// RUN: -parse-stdlib -module-cache-path %t/cache \ | ||
// RUN: -blocklist-file %t/blocklistDisabled.yml \ | ||
// RUN: -sdk %t/sdk -I %t/not_sdk -resource-dir %t/res -I %t/res/host/ \ | ||
// RUN: -F %t/sdk/System/Library/OtherFrameworks/ \ | ||
// RUN: -Rmodule-interface-rebuild -verify | ||
|
||
//--- Empty.swift | ||
|
||
//--- Client_SwiftinterfacesByDefault.swift | ||
/// New behavior | ||
import SDKModule // expected-remark {{rebuilding module 'SDKModule' from interface}} | ||
// expected-note @-1 {{was ignored because the default is to load from module interfaces}} | ||
import SDKModuleAtUnusualPath // expected-remark {{rebuilding module 'SDKModuleAtUnusualPath' from interface}} | ||
// expected-note @-1 {{was ignored because the default is to load from module interfaces}} | ||
import HostResourceDirModule // expected-remark {{rebuilding module 'HostResourceDirModule' from interface}} | ||
// expected-note @-1 {{was ignored because the default is to load from module interfaces}} | ||
import LocalModule // expected-note {{not defaulting to module interface because it is a local module, preferring binary module at}} | ||
import BlocklistedModule // expected-note {{not defaulting to module interface because it was blocklisted, preferring binary module at}} | ||
|
||
//--- Client_SwiftmodulesByDefault.swift | ||
/// Old behavior | ||
import SDKModule // expected-remark {{rebuilding module 'SDKModule' from interface}} | ||
// expected-note @-1 {{was ignored because it belongs to a framework in the SDK}} | ||
import SDKModuleAtUnusualPath | ||
import HostResourceDirModule // expected-remark {{rebuilding module 'HostResourceDirModule' from interface}} | ||
// expected-note @-1 {{was ignored because it's a compiler host module}} | ||
import LocalModule | ||
import BlocklistedModule // expected-remark {{rebuilding module 'BlocklistedModule' from interface}} | ||
// expected-note @-1 {{was ignored because it belongs to a framework in the SDK}} | ||
|
||
//--- blocklistDisabled.yml | ||
--- | ||
ShouldUseBinaryModule: | ||
ModuleName: | ||
- BlocklistedModule | ||
|
||
//--- blocklistEnabled.yml | ||
--- | ||
ShouldUseBinaryModule: | ||
ModuleName: | ||
- Swift_UseSwiftinterfaceByDefault | ||
- BlocklistedModule |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not new in this PR, but what does "host" mean in this context? When I see the diagnostic in the test, I find it a bit confusing since when I read "host" in a compilation context my impression is that it usually refers to a particular role in cross compilation. Here it just means it's in the resource dir, aka the toolchain, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's for macros and refers to a cross-compilation concern, or at least bootstrapping.
@bnbarham Could you remind us why we ignore swiftmodules when
isInResourceHostDir
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really just an issue in our build/test infrastructure, as the modules won't even be there in the toolchain (or at least, they shouldn't be if they are 😅). The issue is that these libraries are built by the "host" (builder/) compiler, but are then read by the just-built compiler when eg. building libraries/executables in the tests. An alternative to this would be building the
swiftmodule
itself elsewhere during the build, I'd be open to that rather than this hack if you'd prefer as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need an option in build systems to not install swiftmodules at some point. For this PR we could improve the proposed diagnostic, it sounds like it will be mostly us seeing it.