-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Warn if a package binary module is loaded from SDK #64600
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: split-file %s %t | ||
|
||
// --- Prepare SDK (.swiftmodule). | ||
// RUN: %empty-directory(%t/SDK) | ||
// RUN: mkdir -p %t/SDK/Frameworks/LibInSDK.framework/Modules/LibInSDK.swiftmodule | ||
// RUN: %target-swift-frontend \ | ||
// RUN: -emit-module \ | ||
// RUN: -module-name LibInSDK \ | ||
// RUN: -package-name libPkg \ | ||
// RUN: -o %t/SDK/Frameworks/LibInSDK.framework/Modules/LibInSDK.swiftmodule/%module-target-triple.swiftmodule \ | ||
// RUN: -swift-version 5 \ | ||
// RUN: %t/Lib.swift | ||
|
||
// RUN: test -f %t/SDK/Frameworks/LibInSDK.framework/Modules/LibInSDK.swiftmodule/%module-target-triple.swiftmodule | ||
|
||
// RUN: %target-swift-frontend -typecheck -verify -verify-ignore-unknown %t/Client1.swift -package-name libPkg -sdk %t/SDK -I %t -I %t/SDK/Frameworks/LibInSDK.framework/Modules | ||
|
||
// RUN: %target-swift-frontend -module-name LibLocal -emit-module -emit-module-path %t/LibLocal.swiftmodule -parse-as-library %t/Lib.swift -package-name libPkg | ||
// RUN: test -f %t/LibLocal.swiftmodule | ||
|
||
// RUN: %target-swift-frontend -typecheck -verify %t/Client2.swift -package-name libPkg -I %t | ||
|
||
//--- Lib.swift | ||
package func log(level: Int) {} | ||
|
||
//--- Client1.swift | ||
import LibInSDK // expected-warning {{module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package should be built locally from source only}} | ||
|
||
func someFunc() { | ||
log(level: 1) | ||
} | ||
|
||
//--- Client2.swift | ||
import LibLocal | ||
|
||
func someFunc() { | ||
log(level: 1) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
// RUN: not %target-swift-frontend -module-name ClientInSamePkg %t/ClientLoadInterfaceModule.swift -emit-module -emit-module-path %t/ClientInSamePkg.swiftmodule -package-name mypkg -I %t 2> %t/resultA.output | ||
// RUN: %FileCheck %s -check-prefix CHECK-A < %t/resultA.output | ||
// CHECK-A: error: module 'LibFromInterface' is in package 'mypkg' but was built from interface '{{.*}}LibFromInterface.swiftinterface'; modules of the same package can only be loaded if built from source | ||
// CHECK-A: error: module 'LibFromInterface' is in package 'mypkg' but was built from interface; modules of the same package can only be loaded if built from source: {{.*}}LibFromInterface.swiftinterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel similar about this error message as the one above, but I'm less sure of another way to word it. As a user I'm just not sure this would mean much to me. Really I want to know what I've done wrong. Maybe this is fine though since IIUC it would be fairly uncommon for a regular user to hit this. |
||
|
||
// RUN: not %target-swift-frontend -module-name ClientInDiffPkg %t/ClientLoadInterfaceModule.swift -emit-module -emit-module-path %t/ClientInDiffPkg.swiftmodule -package-name otherPkg -I %t 2> %t/resultB.output | ||
// RUN: %FileCheck %s -check-prefix CHECK-B < %t/resultB.output | ||
|
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.
Do we use this error somewhere?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, it was already added to SerializationLoader::loadAST in main; its message is just updated in this PR.