Skip to content

Instantly share code, notes, and snippets.

@networkextension
Last active May 8, 2026 10:02
Show Gist options
  • Select an option

  • Save networkextension/4e81b2c8c1df168977429545d1e184da to your computer and use it in GitHub Desktop.

Select an option

Save networkextension/4e81b2c8c1df168977429545d1e184da to your computer and use it in GitHub Desktop.
Swift 6.3 dev on FreeBSD smoke test
# 看现在有哪些 FreeBSD 镜像
gcloud compute images list \
--project freebsd-org-cloud-dev --no-standard-images
# 拉一台 4 核 8G 的 14.x amd64
gcloud compute instances create swift-freebsd \
--image-project=freebsd-org-cloud-dev \
--image-family=freebsd-14-3 \
--zone=us-central1-c \
--machine-type=e2-standard-2 \
--boot-disk-size=50GB
#dl curl -L https://download.swift.org/tmp-ci-nightly/development/freebsd-14_ci_latest.tar.gz -o swift.tar.gz
#doas pkg install compat14x-amd64
test.sh
# 工作目录,干净起步
mkdir -p ~/swift-smoke && cd ~/swift-smoke
# ---- 验证 1: SwiftPM 基本功能 ----
mkdir hello-pm && cd hello-pm
swift package init --type executable
swift build
swift run
cd ..
# ---- 验证 2: 外部依赖、网络、git ----
mkdir hello-dep && cd hello-dep
swift package init --type executable
cat > Package.swift <<'EOF'
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "hello-dep",
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
],
targets: [
.executableTarget(
name: "hello-dep",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]),
]
)
EOF
cat > Sources/main.swift <<'EOF'
import ArgumentParser
struct Hello: ParsableCommand {
@Argument var name: String = "FreeBSD"
func run() { print("hello, \(name)") }
}
Hello.main()
EOF
swift build && swift run hello-dep "Swift on amd64"
cd ..
# ---- 验证 3: swift test ----
mkdir hello-test && cd hello-test
swift package init --type library
swift test
cd ..
# ---- 验证 4: 并发 / async-await / libdispatch ----
mkdir hello-async && cd hello-async
swift package init --type executable
cat > Sources/main.swift <<'EOF'
import Foundation
func work(_ id: Int) async -> Int {
try? await Task.sleep(nanoseconds: 50_000_000)
return id * id
}
@main struct App {
static func main() async {
let results = await withTaskGroup(of: Int.self) { g in
for i in 1...8 { g.addTask { await work(i) } }
var acc: [Int] = []
for await r in g { acc.append(r) }
return acc.sorted()
}
print(results)
}
}
EOF
swift run
cd ..
# ---- 验证 5: BSD-specific syscall (kqueue) via C 互操作 ----
mkdir hello-kqueue && cd hello-kqueue
swift package init --type executable
cat > Sources/main.swift <<'EOF'
#if canImport(Glibc)
import Glibc
#endif
let kq = kqueue()
print("kqueue fd:", kq)
EOF
swift run
cd ..
kqueue@swift-freebsd:~ $ setenv PATH "$PWD/usr/bin:$PATH"
-sh: setenv: not found
kqueue@swift-freebsd:~ $ setenv PATH "$PWD/usr/bin:$PATH"
kqueue@swift-freebsd:~ $ csh
kqueue@swift-freebsd:~ % setenv PATH "$PWD/usr/bin:$PATH"
kqueue@swift-freebsd:~ % swift
Welcome to Swift!
Subcommands:
swift build Build Swift packages
swift package Create and work on packages
swift run Run a program from a package
swift test Run package tests
swift repl Experiment with Swift code interactively
Use `swift --version` for Swift version information.
Use `swift --help` for descriptions of available options and flags.
Use `swift help <subcommand>` for more information about a subcommand.
kqueue@swift-freebsd:~ % sh test.sh
Creating executable package: hello-pm
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-pm/hello_pm.swift
Creating Tests/
Creating Tests/hello-pmTests/
Creating Tests/hello-pmTests/hello_pmTests.swift
Building for debugging...
[8/8] Linking hello-pm
Build complete! (14.86s)
[1/1] Planning build
Building for debugging...
[1/1] Write swift-version--693456239F5F7A9E.txt
Build of product 'hello-pm' complete! (0.36s)
Hello, world!
Creating executable package: hello-dep
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-dep/hello_dep.swift
Creating Tests/
Creating Tests/hello-depTests/
Creating Tests/hello-depTests/hello_depTests.swift
Running resolver because the following dependencies were added: 'swift-argument-parser' (https://github.com/apple/swift-argument-parser)
warning: 'swift-argument-parser': skipping cache due to an error: Failed to clone repository https://github.com/apple/swift-argument-parser:
error: Failed to clone repository https://github.com/apple/swift-argument-parser:
Creating library package: hello-test
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-test/hello_test.swift
Creating Tests/
Creating Tests/hello-testTests/
Creating Tests/hello-testTests/hello_testTests.swift
Building for debugging...
[26/26] Linking hello-testPackageTests.xctest
Build complete! (69.34s)
Test Suite 'All tests' started at 2026-05-08 09:50:36.120
Test Suite 'debug.xctest' started at 2026-05-08 09:50:36.251
Test Suite 'debug.xctest' passed at 2026-05-08 09:50:36.251
Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
Test Suite 'All tests' passed at 2026-05-08 09:50:36.251
Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
◇ Test run started.
↳ Testing Library Version: 6.4-dev (e20dc827e1859df)
↳ Target Platform: x86_64-unknown-freebsd
◇ Test example() started.
✔ Test example() passed after 0.001 seconds.
✔ Test run with 1 test in 0 suites passed after 0.001 seconds.
Creating executable package: hello-async
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-async/hello_async.swift
Creating Tests/
Creating Tests/hello-asyncTests/
Creating Tests/hello-asyncTests/hello_asyncTests.swift
Building for debugging...
[8/8] Linking hello-async
Build of product 'hello-async' complete! (17.20s)
Hello, world!
Creating executable package: hello-kqueue
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-kqueue/hello_kqueue.swift
Creating Tests/
Creating Tests/hello-kqueueTests/
Creating Tests/hello-kqueueTests/hello_kqueueTests.swift
Building for debugging...
[8/8] Linking hello-kqueue
Build of product 'hello-kqueue' complete! (16.68s)
Hello, world!
kqueue@swift-freebsd:~ % git
git: Command not found.
kqueue@swift-freebsd:~ % pkg install git
pkg: Insufficient privileges to install packages
kqueue@swift-freebsd:~ % sudo pkg install git
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
The following 13 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
git: 2.53.0 [FreeBSD]
p5-Authen-SASL: 2.1900 [FreeBSD]
p5-Crypt-URandom: 0.54 [FreeBSD]
p5-Digest-HMAC: 1.05 [FreeBSD]
p5-Error: 0.17030 [FreeBSD]
p5-IO-Socket-SSL: 2.098 [FreeBSD]
p5-MIME-Base32: 1.303 [FreeBSD]
p5-MIME-Base64: 3.16 [FreeBSD]
p5-Mozilla-CA: 20250602 [FreeBSD]
p5-Net-SSLeay: 1.94 [FreeBSD]
p5-URI: 5.34 [FreeBSD]
pcre2: 10.47_1 [FreeBSD]
perl5: 5.42.2 [FreeBSD]
Number of packages to be installed: 13
The process will require 129 MiB more space.
27 MiB to be downloaded.
Proceed with this action? [y/N]: y
[ 1/13] Fetching p5-Net-SSLeay-1.94: 100% 280 KiB 286.3 kB/s 00:01
[ 2/13] Fetching p5-IO-Socket-SSL-2.098: 100% 197 KiB 201.7 kB/s 00:01
[ 3/13] Fetching p5-MIME-Base32-1.303: 100% 8440 B 8.4 kB/s 00:01
[ 4/13] Fetching p5-URI-5.34: 100% 103 KiB 105.8 kB/s 00:01
[ 5/13] Fetching p5-Crypt-URandom-0.54: 100% 17 KiB 17.8 kB/s 00:01
[ 6/13] Fetching pcre2-10.47_1: 100% 1469 KiB 1.5 MB/s 00:01
[ 7/13] Fetching p5-Error-0.17030: 100% 27 KiB 27.5 kB/s 00:01
[ 8/13] Fetching git-2.53.0: 100% 8827 KiB 9.0 MB/s 00:01
[ 9/13] Fetching p5-Authen-SASL-2.1900: 100% 44 KiB 45.3 kB/s 00:01
[10/13] Fetching p5-MIME-Base64-3.16: 100% 22 KiB 22.6 kB/s 00:01
[11/13] Fetching perl5-5.42.2: 100% 16 MiB 16.7 MB/s 00:01
[12/13] Fetching p5-Mozilla-CA-20250602: 100% 123 KiB 126.3 kB/s 00:01
[13/13] Fetching p5-Digest-HMAC-1.05: 100% 15 KiB 14.9 kB/s 00:01
Checking integrity... done (0 conflicting)
[ 1/13] Installing pcre2-10.47_1...
[ 1/13] Extracting pcre2-10.47_1: 100%
[ 2/13] Installing perl5-5.42.2...
[ 2/13] Extracting perl5-5.42.2: 100%
[ 3/13] Installing p5-Crypt-URandom-0.54...
[ 3/13] Extracting p5-Crypt-URandom-0.54: 100%
[ 4/13] Installing p5-Digest-HMAC-1.05...
[ 4/13] Extracting p5-Digest-HMAC-1.05: 100%
[ 5/13] Installing p5-Authen-SASL-2.1900...
[ 5/13] Extracting p5-Authen-SASL-2.1900: 100%
[ 6/13] Installing p5-Error-0.17030...
[ 6/13] Extracting p5-Error-0.17030: 100%
[ 7/13] Installing p5-MIME-Base32-1.303...
[ 7/13] Extracting p5-MIME-Base32-1.303: 100%
[ 8/13] Installing p5-MIME-Base64-3.16...
[ 8/13] Extracting p5-MIME-Base64-3.16: 100%
[ 9/13] Installing p5-Mozilla-CA-20250602...
[ 9/13] Extracting p5-Mozilla-CA-20250602: 100%
[10/13] Installing p5-Net-SSLeay-1.94...
[10/13] Extracting p5-Net-SSLeay-1.94: 100%
[11/13] Installing p5-URI-5.34...
[11/13] Extracting p5-URI-5.34: 100%
[12/13] Installing p5-IO-Socket-SSL-2.098...
[12/13] Extracting p5-IO-Socket-SSL-2.098: 100%
[13/13] Installing git-2.53.0...
===> Creating groups
Creating group 'git_daemon' with gid '964'
===> Creating users
Creating user 'git_daemon' with uid '964'
[13/13] Extracting git-2.53.0: 100%
=====
Message from git-2.53.0:
--
If you installed the GITWEB option please follow these instructions:
In the directory /usr/local/share/examples/git/gitweb you can find all files to
make gitweb work as a public repository on the web.
All you have to do to make gitweb work is:
1) Please be sure you're able to execute CGI scripts in
/usr/local/share/examples/git/gitweb.
2) Set the GITWEB_CONFIG variable in your webserver's config to
/usr/local/etc/git/gitweb.conf. This variable is passed to gitweb.cgi.
3) Restart server.
If you installed the CONTRIB option please note that the scripts are
installed in /usr/local/share/git-core/contrib. Some of them require
other ports to be installed (perl, python, etc), which you may need to
install manually.
kqueue@swift-freebsd:~ % time sh test.sh
mkdir: hello-pm: File exists
Creating executable package: swift-smoke
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/swift-smoke/swift_smoke.swift
Creating Tests/
Creating Tests/swift-smokeTests/
Creating Tests/swift-smokeTests/swift_smokeTests.swift
Building for debugging...
[8/8] Linking swift-smoke
Build complete! (17.28s)
[1/1] Planning build
Building for debugging...
[1/1] Write swift-version--693456239F5F7A9E.txt
Build of product 'swift-smoke' complete! (0.41s)
Hello, world!
Creating executable package: hello-dep
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-dep/hello_dep.swift
Creating Tests/
Creating Tests/hello-depTests/
Creating Tests/hello-depTests/hello_depTests.swift
Running resolver because the following dependencies were added: 'swift-argument-parser' (https://github.com/apple/swift-argument-parser)
Computed https://github.com/apple/swift-argument-parser at 1.7.1 (3.82s)
Building for debugging...
[70/70] Linking hello-dep
Build complete! (85.40s)
[1/1] Planning build
Building for debugging...
[1/1] Write swift-version--693456239F5F7A9E.txt
Build of product 'hello-dep' complete! (0.75s)
Hello, world!
Creating library package: hello-test
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-test/hello_test.swift
Creating Tests/
Creating Tests/hello-testTests/
Creating Tests/hello-testTests/hello_testTests.swift
Building for debugging...
[26/26] Linking hello-testPackageTests.xctest
Build complete! (55.88s)
Test Suite 'All tests' started at 2026-05-08 09:55:11.053
Test Suite 'debug.xctest' started at 2026-05-08 09:55:11.059
Test Suite 'debug.xctest' passed at 2026-05-08 09:55:11.059
Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
Test Suite 'All tests' passed at 2026-05-08 09:55:11.059
Executed 0 tests, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
◇ Test run started.
↳ Testing Library Version: 6.4-dev (e20dc827e1859df)
↳ Target Platform: x86_64-unknown-freebsd
◇ Test example() started.
✔ Test example() passed after 0.001 seconds.
✔ Test run with 1 test in 0 suites passed after 0.001 seconds.
Creating executable package: hello-async
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-async/hello_async.swift
Creating Tests/
Creating Tests/hello-asyncTests/
Creating Tests/hello-asyncTests/hello_asyncTests.swift
Building for debugging...
[8/8] Linking hello-async
Build of product 'hello-async' complete! (16.29s)
Hello, world!
Creating executable package: hello-kqueue
Creating Package.swift
Creating .gitignore
Creating Sources
Creating Sources/hello-kqueue/hello_kqueue.swift
Creating Tests/
Creating Tests/hello-kqueueTests/
Creating Tests/hello-kqueueTests/hello_kqueueTests.swift
Building for debugging...
[8/8] Linking hello-kqueue
Build of product 'hello-kqueue' complete! (16.68s)
Hello, world!
171.602u 214.967s 3:29.21 184.7% 58895+12222k 202+1520io 190pf+0w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment