-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Lift restrictions of access check for inlinalbe package symbols referenced in interfaces. #68811
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
Conversation
|
@swift-ci smoke test |
|
I think we should strive to hide package names from public |
That was my initial thought but after having discussed more with @xymus this way seemed simpler (so users don't have to figure out why they sometimes see package-name and sometimes don't). I'm open to adding more restrictions though. |
|
@swift-ci smoke test |
|
I don't think we should be too concerned about users being confused about why |
zoecarver
left a comment
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.
Yay! Thank you Ellie!
|
If what I'm suggesting is more complicated than I'm imagining to implement, then a version of this approach that would satisfy me more would be to print a placeholder package name instead of the real package name (ideally the placeholder value is known to the compiler and only accepted when parsing interfaces) . |
|
The way is see the alternative suggested by @tshortli would mean to lift the package restriction when building swiftinterfaces, basically treating them as public at that time. I agree that it should work fine, and the real package boundary is enforced during compilation from source and from private swiftinterface. I expect it to be easy enough to implement at this time where only I am not too worried about having the package name in the public swiftinterface at this time either. Only swiftpm automatically sets a package name and we can expect this name to already be public. Adopters in Xcode projects have been setting this value manually. Choosing a package name in Xcode is a similar problem to choosing the module name, leaks can be reported by the same tooling. My main worry about having the package name in the public swiftinterface is for external clients to accidentally use the same package name. The compiler could then error on the import of a module from the same package rebuilt from the swiftinterface. We have a similar problem with module names again. |
|
Modified to print the flag only if the interface contains inlinable (@usableFromInline, @inlinalbe, @_alwaysEmitIntoClient) package decls. |
|
@swift-ci smoke test |
That's an improvement over always printing the package name, but I'd still like to know if just lifting the restriction entirely is a reasonable option so that we never have to print the package name |
|
@swift-ci smoke test |
Package decls are only printed in interface files if they are inlinable (@usableFromInline, @inlinable, @_alwaysEmitIntoClient). They could be referenced by a module outside of its defining module that belong to the same package determined by the `package-name` flag. However, the flag is only in .swiftmodule and .private.swiftinterface, thus type checking references of inlinable package symbols in public interfaces fails due to the missing flag. Instead of adding the package-name flag to the public interfaces, which could raise a security concern, this PR grants access to such cases. Resolves rdar://116142791
Modified to lift restrictions instead. |
|
@swift-ci smoke test |
tshortli
left a comment
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.
Thanks for implementing the approach I suggested! Looks like it turned out reasonably straightforward.
|
@swift-ci smoke test |
Np! Thanks for suggesting and sticking with the approach so we can keep internal details hidden from users. |
|
@swift-ci smoke test windows |
Package decls are only printed in interface files if they are inlinable
(@usableFromInline, @inlinable, @_alwaysEmitIntoClient). They could be
referenced by a module outside of its defining module that belong to the same
package determined by the
package-nameflag. However, the flag is only in.swiftmodule and .private.swiftinterface, thus type checking references of
inlinable package symbols in public interfaces fails due to the missing flag.
Instead of adding the package-name flag to the public interfaces, which
could raise a security concern, this PR grants access to such cases.
Resolves rdar://116142791