Skip to content

OpenBSD port tracking #78437

Open
1 of 1 issue completed
Open
1 of 1 issue completed
@3405691582

Description

@3405691582

Description

Instead of using the forums, use this Github issue to track OpenBSD porting status and notes that are beneficial for other people trying to build Swift on this platform but not necessarily appropriate for putting into prs yet for official documentation.

Notes

Last edit: 2025-06-11.

Building Swift from source without an existing prebuilt toolchain requires a bootstrapping process.

Install required packages:

doas pkg_add bash ninja python%3 e2fsprogs git

Save the following json file for the update-checkout script (compacted for simplicity):

{"ssh-clone-pattern":"git@github.com:%s.git","https-clone-pattern":"https://github.com/%s.git","repos":{"swift":{"remote":{"id":"swiftlang/swift"}},"llvm-project":{"remote":{"id":"swiftlang/llvm-project"}},"cmark":{"remote":{"id":"swiftlang/swift-cmark"}},"llbuild":{"remote":{"id":"swiftlang/swift-llbuild"}},"swift-build":{"remote":{"id":"swiftlang/swift-build"}},"swift-argument-parser":{"remote":{"id":"apple/swift-argument-parser"}},"swift-collections":{"remote":{"id":"apple/swift-collections"}},"swift-crypto":{"remote":{"id":"apple/swift-crypto"}},"swift-certificates":{"remote":{"id":"apple/swift-certificates"}},"swift-asn1":{"remote":{"id":"apple/swift-asn1"}},"swift-driver":{"remote":{"id":"swiftlang/swift-driver"}},"swift-toolchain-sqlite":{"remote":{"id":"swiftlang/swift-toolchain-sqlite"}},"swift-tools-support-core":{"remote":{"id":"swiftlang/swift-tools-support-core"}},"swiftpm":{"remote":{"id":"swiftlang/swift-package-manager"}},"swift-syntax":{"remote":{"id":"swiftlang/swift-syntax"}},"swift-system":{"remote":{"id":"apple/swift-system"}},"swift-corelibs-xctest":{"remote":{"id":"swiftlang/swift-corelibs-xctest"}},"swift-corelibs-foundation":{"remote":{"id":"swiftlang/swift-corelibs-foundation"}},"swift-foundation-icu":{"remote":{"id":"swiftlang/swift-foundation-icu"}},"swift-foundation":{"remote":{"id":"swiftlang/swift-foundation"}},"swift-corelibs-libdispatch":{"remote":{"id":"swiftlang/swift-corelibs-libdispatch"}},"swift-experimental-string-processing":{"remote":{"id":"swiftlang/swift-experimental-string-processing"}}},"default-branch-scheme":"main","branch-schemes":{"main":{"aliases":["swift/main","main","stable/20240723"],"repos":{"llvm-project":"stable/20240723","swift":"main","cmark":"gfm","llbuild":"main","swift-build":"main","swift-toolchain-sqlite":"1.0.1","swift-tools-support-core":"main","swiftpm":"main","swift-argument-parser":"1.4.0","swift-collections":"main","swift-crypto":"main","swift-certificates":"main","swift-asn1":"main","swift-driver":"main","swift-syntax":"main","swift-system":"main","swift-corelibs-xctest":"main","swift-corelibs-foundation":"main","swift-foundation-icu":"main","swift-foundation":"main","swift-corelibs-libdispatch":"main","swift-experimental-string-processing":"swift/main"}}}}

Check out swiftlang/swift.

Use the following update-checkout command:

./swift/utils/update-checkout --clone --config ./update-checkout-config.json --github-comment 'apple/swift-crypto#352'

Manual changes required:

Other manual changes not described here may be required and will eventually be upstreamed or discussed further here.

Generally, the build process will be

env ./swift/utils/build-script --preset=bootstrap_stage0_openbsd \
        build_subdir=bootstrap0 install_destdir=install0
env PATH=<path to...>/install0/usr/bin/:${PATH} ./swift/utils/build-script --preset=bootstrap_stage1_openbsd \
        build_subdir=bootstrap1 install_destdir=install1
env PATH=<path to...>/install1/usr/bin/:${PATH} ./swift/utils/build-script --preset=bootstrap_stage2_openbsd \
        build_subdir=bootstrap2 install_destdir=install2

This is not a fully refined process yet, so if you attempt these steps verbatim there may still be problems.

  • Needs investigation/known issues (roughly in priority order)
    • Blockers:
      • Currently the default configuration builds Swift with BTCFI disabled to work around a bug triggered by Concurrency. This should be remedied.
      • Dispatch queues can possibly trigger platform threading bugs that ld.so's allocator detects (but kills the program). Work around these by manually disabling threading for now.
    • Not blockers/unknown
      • A durable solution to Synchronization should be found.
      • threading can be problematic: swiftc -num-threads can be memory-hungry and cause lockups.

Sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions