-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenBSD port tracking #78437
Comments
I've assigned you on this issue.
Have you tried turning off inline bridging mode, as currently done for Windows and as I used to do for Android? I suggest you apply to be a committer if you plan to work on this port more. I can't say if you will get it, as I don't decide that, but based on your extensive track record, I suspect you will. |
Note that yams has been removed in trunk, #78826. |
I've experienced trouble with both PURE and INLINE bridging modes. Thankfully by turning interop off for now this sidesteps the issue and haven't been forced to deal with this problem further yet, though I likely will eventually. |
OK, pure bridging also stopped working for me natively on Android last March in trunk, but worked for building 5.10. You may want to try it with 5.10 on OpenBSD and see if that works. At the very least, that could give you a working "standard toolchain" that you could use to bootstrap everything else.
Yes, you will need it, as more and more of the compiler is written in Swift and directly calls LLVM/Swift C++ APIs inside the compiler.
It does work, as most Swift platforms currently use libc++, such as all Darwin platforms and Android. Egor even got it working on linux, #75589. That said, it can be a bit flaky and required some small changes to work on Android.
That module is added in this repo, you may just need to enable OpenBSD there, as Alex did for Android.
That's surprising, as libc++ has shipped with a module map for years now. If OpenBSD is not including it for some reason, try copying it over and using it. |
I have what I think is a janky standard toolchain already atop HEAD/6.2 with C++ interop turned off, but granted, the next step is testing it to make sure it actually properly incorporates the Swift compiler sources. These are good breadcrumbs for when I get back to trying to reenable interop, thanks! |
@3405691582, thanks for your work on the OpenBSD port! We've recently open sourced Xcode's build system engine (Swift Build) which will eventually become part of the toolchain. I'm currently working on adding FreeBSD support there, and I expect OpenBSD support would be a similar change. Thought I'd mention it here so you can make sure you're aware of potential changes needed in this space. I filed an issue to track: swiftlang/swift-build#114 |
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-02-04.
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.#if SWIFT_BUILD_SWIFT_SYNTAX
guards aroundASTScopeImpl::unqualifiedLookup
inASTScope::unqualifiedLookup
inlib/AST/ASTScope.cpp
.SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
andSWIFT_IMPLICIT_CONCURRENCY_IMPORT
; but you must turn these on for the bootstrap toolchain.To create the bootstrap toolchain (mostly complete/in progress):
swift-corelibs-libdispatch
,swift-corelibs-foundation
,swift-foundation
,swift-collections
,swift-foundation-icu
.swift-foundation
.stdlib/public/Synchronization/Mutex.swift
usingpthread_mutex_t?
, or use the 5.10 version of Foundation.stdlib/public/Synchronization/CMakeLists.txt
.pthread_mutex_t
could be a value type with internal pointers, this should be safe enough for now since OpenBSD uses a pointer forpthread_mutex_t
.swift-corelibs-foundation
is the one prior toMutex
being adopted.build-script
:--install-swift --install-foundation --install-xctest --install-libdispatch
.SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
,SWIFT_BUILD_REGEX_PARSER_IN_COMPILER
andSWIFT_ENABLE_SYNCHRONIZATION
if they are not on already; Foundation needs these turned on.SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP
to turn off C++ interop.CxxStdlib
). Moreover, OpenBSD's C++ includes are missing a modulemap.target_compile_options(FoundationEssentials PRIVATE "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -disable-large-loadable-types-reg2mem>")
toSources/FoundationEssentials/CMakeLists.txt
.FoundationEssentials
(and not just on OpenBSD);LoadableByAddress
pass ingetAddressForValue
when buildingFoundationEssentials
#78954.FoundationEssentials
has errorif any output files are specified, they all must be
_FoundationCShims
and_FoundationCollections
as files and not library flags.To create the standard toolchain (mostly complete/in progress):
swift-driver
andswiftpm
. You could potentially skip buildingswiftpm
, but other platforms do include it.swift-driver.
swift-llbuild
(as llbuild),swift-tools-support-core
,swift-argument-parser
andswift-driver
.backtrace
from libexecinfo. swift-llbuild#972-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
.target_link_options(Foundation PRIVATE "LINKER:-z" "LINKER:origin")
inswift-corelibs-foundation
andtarget_link_options(${target} PRIVATE "LINKER:-z" "LINKER:origin")
inswift-syntax
'sAddSwiftHostLibrary.cmake
add_compile_options
to Dispatch and llbuild'sCMakeLists.txt
, since by default they use the just-built Clang.swift-system
,swift-crypto
,swift-asn1
,swift-certificates
, andswift-package-manager
(asswiftpm
)swift-crypto
needs platform conditionals inSources/CCryptoBoringSSL/CMakeLists.txt
otherwise there is an unhelpful cmake error.swift-crypto
also has dependencies onManagedBuffer.capacity
. Some of this is easy to disentangle, but some requires more aggressive refactoring. This is the current blocker on buildingswiftpm
presently.env PATH=<path to the installed toolchain above>
when invokingbuild-script
.swiftpm
,swift-driver
will build fine, but the installer bootstrap will fail since it assumes that swiftpm exists already. This can be worked around, though.Needs investigation:
swiftc -num-threads
can be memory-hungry and cause lockups; check and make sure threading is WAIamd64
at some point.The text was updated successfully, but these errors were encountered: