I am bootstrapping Swift 5.10.1 on FreeBSD 13.4 and have encountered some linking problems. The linker I use is lld. The C++ compiler is clang 15.0.7 from FreeBSD ports/packages.
With my local fixes if the build configuration for Swift is RelWithDebInfo (build-script --release-debuginfo) everything builds fine and most of the tests pass. If the build configuration is Debug however (build-script --release-debuginfo --debug-swift), when the CMake target 'swift-frontend-bootstrapping1' is being linked I get a linker error about missing symbols from libswiftSwiftOnoneSupport.so.
I see that when the build configuration is Debug 'swiftSwiftOnoneSupport-bootstrapping0' is added as a dependency of 'swiftCompilerModules-bootstrapping1' which is a dependency of 'swift-frontend-bootstrapping1'.
However, a library being a direct or indirect dependency of an executable doesn't mean that it will be passed to the linker when linking the executable.
I feel that either a target_link_libraries(swift-frontend-bootstrapping1 swiftSwiftOnoneSupport-bootstrapping0) command is needed in order to explicitly specify the linking requirement or some autolinking mechanism is failing.
FreeBSD is a non-Darwin platform and doesn't have an autolink. In the llvm-project git repository in the tag 'swift-5.10.1-RELEASE' I see some code for autolinking that relies on the ELF section '.swift1_autolink_entries'. The object files in 'libswiftCompilerModules-bootstrapping1.a' all have the '.swift1_autolink_entries' section which specifies '-lswiftSwiftOnoneSupport' among others. However, nothing I've seen in the documentation suggests that one should use clang built from git tag 'swift-5.10.1-RELEASE' when building Swift.
How is linking SwiftOnoneSupport supposed to work during bootstrapping? I want it to work on FreeBSD as well as on all Darwin platforms and Linux.
That's a couple years old, the latest release is LLVM 19.1.
I don't think that debug build is regularly built on the CI, so it regresses sometimes. See if somebody has opened an issue for it already on github or proposed a fix.
It could be broken on linux too, you'd have to build the same source on linux to check.
By default, the Swift build uses the prebuilt system compiler, clang 15 in your case, to build the Swift-forked LLVM and the C++ portions of the Swift compiler, but then uses the freshly-built Swift-forked clang to build the C++ files in the Swift standard library.
So now that portions of the Swift compiler are written in Swift, both clang compilers will be used to compile parts of the Swift compiler.
Without the failing command and error, we can't know what is going wrong for you and it could very well be broken on linux too.
I discovered the source of my linking troubles. If you do 'build-script --bootstrapping bootstrapping --release-debuginfo --debug-swift', the build configuration will be Debug for most of the code in the swift directory. However, the build configuration for the Swift standard library will be RelWithDebInfo.
In the file swift/SwiftCompilerSources/CMakeLists.txt the variable CMAKE_BUILD_TYPE has value Debug and SwiftOnoneSupport is considered needed. In the file swift/stdlib/cmake/modules/AddSwiftStdlib.cmake SWIFT_STDLIB_BUILD_TYPE has the value RelWithDebInfo and the code decides that SwiftOnoneSupport is not needed. The discrepancy in the build configurations causes the linking problem. It seems to only happen when bootstrapping.
When using 'build-script --bootstrapping bootstrapping --release-debuginfo --debug-swift --debug-swift-stdlib' the bootstrap completes successfully.