-
Notifications
You must be signed in to change notification settings - Fork 336
Use FoundationEssentials if it's available #674
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
@swift-ci test |
This feature will also be very useful to me. After applying the patch locally I still see
This is my last Foundation dependency for a particular daemon which will shrink the stripped/release/static stdlib size from 62MB to 14MB. |
After applying the patch:
It turns out we need to enable Swift 6 language mode for the
What we could do is only use That still leaves |
@swift-ci Please test |
@@ -9,9 +9,14 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#if swift(>=5.11) | |||
#if swift(>=6.0) |
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.
See previous comment that Swift 6 language mode needs to be enabled for these guards to work (which it is not in Package.swift).
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.
Should be addressed by using #if compiler
instead, as in provided suggestions.
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.
Good catch, thanks @MaxDesiatov!
@@ -9,9 +9,14 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#if swift(>=5.11) | |||
#if swift(>=6.0) |
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.
#if swift(>=6.0) | |
#if compiler(>=6.0) |
internal import protocol Foundation.LocalizedError | ||
internal import class Foundation.NSError | ||
#endif | ||
#elseif swift(>=5.10) |
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.
#elseif swift(>=5.10) | |
#elseif compiler(>=5.10) |
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.
Ok this actually exposes an issue - NSError
isn't part of Foundation Essentials. Are folks happy to remove that check?
@@ -119,11 +120,7 @@ enum MessageInfo { | |||
case let error as LocalizedError where error.errorDescription != nil: | |||
self = .other(message: error.errorDescription!, exitCode: .failure) | |||
default: | |||
if Swift.type(of: error) is NSError.Type { |
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.
NSError
does not exist in Foundation Essentials so I've removed this check and defaulted to String(describing:)
. What are folks thoughts on this? Seems excessive to bring in all of Foundation just for this
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.
If we really want to preserve the behavior we can use reflection (ArgumentParser
already depends on it heavily), but that's really overkill.
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.
@0xTim - what's the difference in behavior? Can you try throwing an NSError so we can make sure it isn't a quality regression?
This still isn't working for me on Linux.
The issue is the one I described before:
|
Use
FoundationEssentials
if it's available. This stops all of Foundation being linked when not needed and reduces binary sizesChecklist