You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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-01-20.
Currently the project contains a percentage of C++ dependencies. However, Swift will eventually be written with critical components in Swift, requiring us to build a bootstrap toolchain. Therefore, there are three main different types of build output to think about, namely,
the legacy compiler toolchain containing just the legacy Swift libraries and compiler (i.o.w., no Dispatch, no Foundation)
the bootstrap toolchain containing the legacy compiler toolchain plus the minimal set of dependencies to build the standard toolchain components written in Swift (swift-driver, etc.)
the standard toolchain, including components written in Swift
The legacy compiler toolchain is more or less working, but is not broadly useful. The standard toolchain is not completed yet. We need to create a bootstrap toolchain, since there is no prebuilt toolchain for OpenBSD, and we will eventually need one in the future to build Swift after some point.
To create the legacy compiler toolchain (complete):
You will also likely need to turn on SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING, SWIFT_BUILD_REGEX_PARSER_IN_COMPILER and SWIFT_ENABLE_SYNCHRONIZATION if they are not on already.
There is an upstream LLVM issue that means that clang as-built from LLVM will crash when generating machine code with stack protection on arm64. This affects swift-corelibs-libdispatch and swift-foundation-icu. Work around it by temporarily disabling stack protection with -fno-stack-protector.
Foundation build for FoundationEssentials has error if any output files are specified, they all must be
this is due to cmake adding the static library dependencies for _FoundationCShims and _FoundationCollections as files and not library flags.
even working around that, the Release compiler crashes (and not just on OpenBSD).
Linux doesn't seem to have this problem with 6.0 but does on 6.1. OpenBSD has a similar (same?) problem with 6.0.
Debug compiler might actually be working now at HEAD.
I think Swift's C++ interop doesn't work with libc++ platforms and needs to be provided for C++ interop to work. (I think this is why there are errors about a missing Clang module for CxxStdlib). Moreover, OpenBSD's C++ includes are missing a modulemap. Workaround with turning SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP off, but this is probably going to be required as progress is made.
We likely need an implementation for stdlib/public/Synchronization/Mutex.swift, since Foundation seems to have dependencies. Work around with the 5.10 version of swift-corelibs-foundation, which is the one prior to Mutex being adopted.
To create the standard toolchain (very incomplete):
Prepare repositories, as per above.
Prepare additional repositories: dependencies for swift-driver.
Clone swift-llbuild (as llbuild), swift-tools-support-core, swift-argument-parser and Yams (as yams).
llbuild needs the same -Xlinker -Bsymbolic change and temporary -fno-stack-protector change.
llbuild and TSC built with cmake includes -lc for some reason linking libllbuildSwift, which gives a duplicate symbol error with atexit at link time. Workaround by clearing CMAKE_C_IMPLICIT_LINK_LIBRARIES and/or CMAKE_CXX_IMPLICIT_LINK_LIBRARIES .
Needs investigation:
swiftc -num-threads can be memory-hungry and cause lockups; check and make sure threading is WAI
Even with using the "minimal" bootstrap toolchain (without Foundation) and --skip-early-swift-driver to build the Swift, there are a number of issues with modules that prevent a successful build. Current suspicion is bad libc++ interaction with modules and/or existing upstream bugs with modules.
A less drastic workaround for the upstream clang crash is necessary.
Check this all works back on amd64 at some point.
The text was updated successfully, but these errors were encountered:
there are a number of issues with modules that prevent a successful build. Current suspicion is bad libc++ interaction with modules and/or existing upstream bugs with modules.
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-01-20.
Currently the project contains a percentage of C++ dependencies. However, Swift will eventually be written with critical components in Swift, requiring us to build a bootstrap toolchain. Therefore, there are three main different types of build output to think about, namely,
The legacy compiler toolchain is more or less working, but is not broadly useful. The standard toolchain is not completed yet. We need to create a bootstrap toolchain, since there is no prebuilt toolchain for OpenBSD, and we will eventually need one in the future to build Swift after some point.
To create the legacy compiler toolchain (complete):
#if hasFeature(Macros)
in stdlib/public/core/SwiftifyImport.swift as well.SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
andSWIFT_IMPLICIT_CONCURRENCY_IMPORT
; but you must turn these on for the bootstrap toolchain.To create the bootstrap toolchain (in progress/incomplete):
swift-corelibs-libdispatch
,swift-corelibs-foundation
,swift-foundation
,swift-collections
,swift-foundation-icu
.swift-corelibs-foundation
.swift-foundation
.SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
,SWIFT_BUILD_REGEX_PARSER_IN_COMPILER
andSWIFT_ENABLE_SYNCHRONIZATION
if they are not on already.swift-corelibs-libdispatch
andswift-foundation-icu
. Work around it by temporarily disabling stack protection with-fno-stack-protector
.FoundationEssentials
has errorif any output files are specified, they all must be
_FoundationCShims
and_FoundationCollections
as files and not library flags.CxxStdlib
). Moreover, OpenBSD's C++ includes are missing a modulemap. Workaround with turningSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP
off, but this is probably going to be required as progress is made.stdlib/public/Synchronization/Mutex.swift
, since Foundation seems to have dependencies. Work around with the 5.10 version ofswift-corelibs-foundation
, which is the one prior toMutex
being adopted.To create the standard toolchain (very incomplete):
swift-llbuild
(as llbuild),swift-tools-support-core
,swift-argument-parser
andYams
(as yams).-Xlinker -Bsymbolic
change and temporary-fno-stack-protector
change.-lc
for some reason linkinglibllbuildSwift
, which gives a duplicate symbol error withatexit
at link time. Workaround by clearingCMAKE_C_IMPLICIT_LINK_LIBRARIES
and/orCMAKE_CXX_IMPLICIT_LINK_LIBRARIES
.Needs investigation:
swiftc -num-threads
can be memory-hungry and cause lockups; check and make sure threading is WAI--skip-early-swift-driver
to build the Swift, there are a number of issues with modules that prevent a successful build. Current suspicion is bad libc++ interaction with modules and/or existing upstream bugs with modules.amd64
at some point.The text was updated successfully, but these errors were encountered: