Skip to content
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

FreeBSD support #315

Merged
merged 2 commits into from
Dec 16, 2024
Merged

FreeBSD support #315

merged 2 commits into from
Dec 16, 2024

Conversation

michael-yuji
Copy link
Member

Fix FreeBSD support

Checklist

  • I've run tests to see all new and existing tests pass
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Motivation:

To add FreeBSD support to Swift, we must ensure that swift crypto builds on FreeBSD since it's a dependency of swiftpm and several essential packages.

Modifications:

  • Package.swift - Ideally FreeBSD should use .when(platforms:) to set the corresponding swift settings and dependencies. However, Platform.freebsd is not yet available on swiftpm and therefore use guard the settings behind a isFreeBSD boolean flag. This is chosen because it minimize the diff and maintains the maximum readability.
  • cmake/modules/SwiftSupport.cmake - add amd64 arch support, maps to x86_64.
  • **/CMakeLists.txt - Use the Linux assembly files for FreeBSD. Both Linux and FreeBSD uses SysV ABI, and there're no syscalls involved (after all, they're supposed to be "pure") so there are no ABI compatibility problem. After all, all the tests are passing on FreeBSD with this PR.

Result:

All the tests (via swift test) passed on x86_64 FreeBSD 14.1-p6, and passed on aarch64 macOS.

Test log available here: swift-test-result.txt

…` boolean

`Platform.freebsd` is not yet available on swift-pm. Therefore we guard the
settings and dependencies behind a `isFreeBSD` boolean instead.
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Dec 16, 2024
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Thanks for this! Hopefully we'll get a FreeBSD CI environment to prevent this regressing, but for now this looks totally reasonable. Nice one! ✨

@Lukasa Lukasa merged commit bce1725 into apple:main Dec 16, 2024
33 of 34 checks passed
// Ideally, we should use `.when(platforms:)` to set `swiftSettings` and
// `dependencies` like on other platforms. However, `Platform.freebsd` is not
// yet available, and therefore we guard the settings behind this boolean.
#if os(FreeBSD)

Choose a reason for hiding this comment

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

Want to use .custom() here @michael-yuji?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants