Skip to content

Explicitly only use FoundationEssentials where possible #436

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 3 commits into from
Dec 20, 2024

Conversation

t089
Copy link
Contributor

@t089 t089 commented Dec 20, 2024

We want that the runtime only depends on FoundationEssentials where available (ie. on linux) to ensure small binary size.

Motivation:

Smaller binary size is good for lambda deployment and cold-start times. The runtime should only depend on FoundationEssentials.

Modifications:

  • replace import Foundation with import FoundationEssentials if FoundationEssentials is available.
  • I also applied the same treatment to tests to ensure that catch error where tests run on linux and we use API that is only available in Foundation which easily happens when you develop on macOS (where always full Foundation is available).

Result:

This should allow builds without linking full Foundation.

@sebsto sebsto added the semver/none No version bump required. label Dec 20, 2024
@sebsto
Copy link
Contributor

sebsto commented Dec 20, 2024

Thank you @t089
Can you run the Swift format script to fix the formatting issue ?

@t089
Copy link
Contributor Author

t089 commented Dec 20, 2024

Thank you @t089 Can you run the Swift format script to fix the formatting issue ?

why do I always forget this? on it ...

Copy link
Contributor

@sebsto sebsto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sebsto sebsto merged commit 25eb6e1 into swift-server:main Dec 20, 2024
24 checks passed
@t089 t089 deleted the foundation-essentials branch December 22, 2024 09:21
sebsto added a commit that referenced this pull request Dec 25, 2024
#441)

This adds a test in the `integration_test.yml` workflow to verify that
`libFoundation.so`, `libFoundationInternationalization.so`, and
`lib_FoundationICU.so` and not linked the the function binary.

This is a follow up from the work make by @t089 to ensure that we don't
accidentally link Foundation again in the future.

Remove Foundation :
#436
Add test in CI to ensure we don't link to foundation :
#402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants