Add FreeBSD platform support#565
Open
networkextension wants to merge 4 commits into
Open
Conversation
Introduces a `FreeBSDPlatform` target (`struct FreeBSD: Platform`) so swiftly compiles and runs on FreeBSD, alongside the existing Linux and macOS platforms. - New `FreeBSDPlatform` target, modeled on `LinuxPlatform` (FreeBSD's toolchain layout is tarball-based like Linux). `detectPlatform` returns a single `.freebsd` `PlatformDefinition`; install/extract/dirs reuse the portable POSIX/Foundation paths. - Wired into `Swiftly`/`TestSwiftly` (`#elseif os(FreeBSD)`), and the POSIX `os(macOS) || os(Linux)` guards in `SwiftlyCore` (ProcessInfo, Platform, Platform+Process, Terminal) now include FreeBSD. - Added `PlatformDefinition.freebsd`. - `FreeBSDPlatform` is an unconditional package dependency that self-guards with `#if os(FreeBSD)`, because `PackageDescription` currently has no `.freebsd` platform (so `.when(platforms: [.freebsd])` is unavailable). - The release-packaging tool's `run()` throws on FreeBSD for now (the Linux release path is musl-SDK specific). Verified: builds and runs (`swiftly --help` / `--version`) natively on FreeBSD 15.1/aarch64.
Two follow-ups to the FreeBSDPlatform support: - FreeBSD.swift: verifySwiftlySystemPrerequisites checked the Linux CA bundle paths (/etc/ssl/certs/ca-certificates.crt, /etc/pki/tls/certs/ca-bundle.crt), which don't exist on FreeBSD, so it always reported "ca-certificates not installed". Check the FreeBSD trust store instead: /usr/local/etc/ssl/cert.pem (security/ca_root_nss), /etc/ssl/cert.pem (base), and /usr/local/share/certs/ca-root-nss.crt. - SwiftlyTests.swift: the MockToolchainDownloader helpers (makeMockedSwiftly/makeMockedToolchain, the signatures cache, and the on-disk toolchain verifier) were guarded #if os(Linux)/#elseif os(macOS) only, so the test target failed to compile on FreeBSD. Add os(FreeBSD) to the Linux branches; the Linux mock builds a .tar.gz + GPG signature, which is exactly what FreeBSDPlatform consumes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
You can use |
…rm dep Per review feedback (@kkebo): instead of depending on FreeBSDPlatform unconditionally (and relying on the target's internal `#if os(FreeBSD)` self-guard), gate the dependency with `.when(platforms: [.custom("freebsd")])`, matching the LinuxPlatform/MacOSPlatform entries. This keeps FreeBSDPlatform out of the dependency graph entirely on non-FreeBSD builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Thanks @kkebo — that's much cleaner. Applied in 4f25b50: the three |
SelfUpdate.execute hit `fatalError("Unsupported OS")` on FreeBSD, which
crashed the whole test process (SIGTRAP) and aborted the suite. Treat
FreeBSD like Linux (tarball-based): build a freebsd/swiftly-*.tar.gz
download URL for an explicitly-requested version, and match the Linux
release artifact in the auto-update path (the swift.org website API has
no FreeBSD platform yet; this can switch to a dedicated FreeBSD artifact
once one is published).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a
FreeBSDPlatformtarget so swiftly compiles and runs on FreeBSD, alongside the existing Linux and macOS platforms.Approach
FreeBSDPlatform(struct FreeBSD: Platform), modeled onLinuxPlatformsince FreeBSD's Swift toolchains are tarball-based like Linux.detectPlatformreturns a singlePlatformDefinition.freebsd; the install/extract/directory logic reuses the portable POSIX/Foundation paths.SwiftlyandTestSwiftlyselect it via#elseif os(FreeBSD), and the POSIXos(macOS) || os(Linux)guards inSwiftlyCore(ProcessInfo,Platform,Platform+Process,Terminal) now include FreeBSD.PlatformDefinition.freebsd.FreeBSDPlatformis gated with.when(platforms: [.custom("freebsd")])(thanks @kkebo), matching theLinuxPlatform/MacOSPlatformentries —PackageDescriptionhas no.freebsdcase, but.custom("freebsd")works, so it stays out of the graph on non-FreeBSD builds.run()throws on FreeBSD for now (the Linux release path is musl-SDK specific).Testing
Builds and runs natively on FreeBSD 15.1 / aarch64 (
swiftly --help,swiftly --version) with a nativeswift-6.3.2-RELEASEtoolchain.