Glad to see interest in the project.
Starting from a Swift 6.3.2 release toolchain built in a prior phase, I bootstrapped Swift 6.4-dev natively on the board using --bootstrapping=hosttools. This mode is required since Swift 6.3+ uses macros in the stdlib, so the host and target compiler revisions must match exactly — any mismatch produces AccessorDeclSyntax.modifiers missing or @_spi inaccessible errors deep in the build.
A lot of the --bootstrapping=* flags are a bit misleading and don't really work anymore.
This was the script I used to do a four-stage Swift 6.2 bootstrap to bring up the x86_64 support:
#!/usr/bin/env bash
set -ex
SOURCE_ROOT="$HOME/Swift-Project"
STAGE_ROOT="$SOURCE_ROOT/Swift-Package/Stages"
INSTALL_ROOT="$SOURCE_ROOT/Swift-Package/toolchain"
BUILD_SCRIPT="$SOURCE_ROOT/swift/utils/build-script"
mkdir -p "$STAGE_ROOT" "$INSTALL_ROOT"
"$BUILD_SCRIPT" \
--preset=bootstrap_stage0 \
build_subdir=bootstrap_stage0 \
install_destdir="$STAGE_ROOT/stage0"
export LLVM_SYMBOLIZER_PATH="$SOURCE_ROOT/build/bootstrap_stage0/llvm-linux-x86_64/bin/llvm-symbolizer"
PATH="$STAGE_ROOT/stage0/usr/bin/:$PATH" \
"$BUILD_SCRIPT" \
--preset=bootstrap_stage1 \
build_subdir=bootstrap_stage1 \
install_destdir="$STAGE_ROOT/stage1"
PATH="$STAGE_ROOT/stage1/usr/bin/:$PATH" \
"$BUILD_SCRIPT" \
--preset=bootstrap_stage2 \
build_subdir=bootstrap_stage2 \
install_destdir="$STAGE_ROOT/stage2"
PATH="$STAGE_ROOT/stage2/usr/bin:$PATH" \
"$BUILD_SCRIPT" \
--preset=freebsd_package,no_test \
install_destdir="$INSTALL_ROOT" \
installable_package="$INSTALL_ROOT/swift-main-freebsd.tar.gz"
6.2 was the last toolchain version that we ensured could bootstrap from a pure C++ environment to a fully-working, tests-passing, toolchain (did the work on Ubuntu 24.04, which we already supported to separate bootstrap failures from missing platform support. I don't believe 6.0 or 6.1 can successfully, bootstrap, and I don't know about the 6.3 release either, though we left the CI job running long enough that it might work.
The fully bootstrapped 6.2 compiler should be able to compile the main compiler and at least looking at your repo, it looks like you're cross-compiling.
Getting swift build to work required two patches to my workflow:
- ProcessInfo.executableURL returns nil. SwiftPM uses this to locate the compiler. On Linux it reads /proc/self/exe; FreeBSD has no /proc by default. SwiftPM falls back to $PWD/swiftc. Fix: create a symlink before building and remove it after.
I'm a little surprised that this workaround is still necessary. It should have been fixed by:
- SWBBuildService computes a wrong path. The new build system generates a double usr/usr prefix for plugin paths on FreeBSD, causing the Driver to throw and invalid absolute path ''. The old LLBUILD backend works correctly: --build-system native.
Do you have info on how to reproduce this? @jakepetroules, did we see anything like this thus far?
I haven't dug into the Swiftly/Swift-NIO side of things yet, so cool to see someone looking at that. I added your optimizer miscompile issue to the FreeBSD project board Swift on FreeBSD · GitHub so that we can track it.