Please consider support FreeBSD, if Swift wants to target Server market, Netflix, Trivago, and iXsystem all use FreeBSD. and libdispatch have been support in FreeBSD way back to 2015, but it need maintainance and let swift run on top of it.
I agree that having FreeBSD support would be great. For Swift to make a serious dent, it needs to to support Windows and FreeBSD.
Regarding __stdlib_remainder()
and __stdlib_squareRootl()
not being found, I believe this stems from not having a typealias for CLongDouble
.
It certainly seems counterintuitive, but if you look in stdlib/public/core/CTypes.swift
you will find code where OS and architecture are considered and a CLongDouble
possibly defined. Adding an #elseif
case for my OS and includingâŚ
public typealias CLongDouble = Float80
⌠cleared up the problem for me.
Depending on your architecture, you may also have to adjust the guards in stdlib/public/SwiftShims/LibcShims.h
.
Any Christmas gifts for BSD lovers?
OpenBSD is the lucky one, someone has ported swift to Openbsd.
I hope FreeBSD can also get some love from Swift Community
Great to read that! I also hope for FreeBSD to be on the list if supported OS.
The OpenBSD port has been done!
Whatâs the best things to do to port Swift to FreeBSD 13.1 ? And how much!?
Whatâs the best things to do to port Swift to FreeBSD 13.1 ? And how much!?
I would encourage you or anyone else interested to look at the pulls making up @3405691582's OpenBSD port over the last couple years, which give you an idea of the work involved, as I noted on another FreeBSD thread late last year. FreeBSD may be less work, as I already see some support merged.
Anything new here?
This is a good sign.
Maybe not. They list lots of other platforms, but not FreeBSD.
Has anybody gotten swift on FreeBSD to work ? I've tried the excellent instructions on swift/FreeBSD.md at freebsd-docs ¡ mhjacobson/swift ¡ GitHub inside a FreeBSD 13.2 jail (applying the module patch on the basejail) and gotten to the point during the build where ninja starts to compile swift code.
Now I get a segmentation fault in
4. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module Swift)
5. While silgen emitFunction SIL function "@$ss3minyxx_xxxdtSLRzlF".
for 'min(_:_:_:_:)' (at /root/swift/swift/stdlib/public/core/Algorithm.swift:38:8)
But I have no idea how to debug ninja. I've loaded the core in lldb but there is not really anything there
[root@swift ~/swift/build]# lldb -c ./tools/swift/stdlib/public/core/swift-frontend.core
(lldb) target create --core "./tools/swift/stdlib/public/core/swift-frontend.core"
Core file '/root/swift/build/tools/swift/stdlib/public/core/swift-frontend.core' (x86_64) was loaded.
(lldb) bt all
* thread #1, name = 'swift-frontend', stop reason = signal SIGSEGV
* frame #0: 0x0000000001a64933
frame #1: 0x000000087cc8e300
(lldb)
Any idea how to get it running ? I've tried contacting the author of the FreeBSD build instructions, but got no answer. That's why I'm shouting out here for help.
I think once the Swift 5.9 and new swift based Foundation library become stable, we can re investigate this problem.
What version of Swift are you building? What is the failing command? I assume this is FreeBSD amd64.
I've seen a similar error when bootstrapping on linux x86_64: try turning the bootstrap off, -DBOOTSTRAPPING_MODE:STRING=OFF
.
Thanx for the hint - as said I'm using the configure script from mhjacobson/swift , which has
-DBOOTSTRAPPING_MODE=BOOTSTRAPPING
enabled.
I did disable it and ..... it compiled fine!!!
I just ran my first 'hello world' on freebsd:
[root@swift ~/swift/build/bin]# ./swift helloworld.swift
hello world
[root@swift ~/swift/build/bin]#
swiftc to compile it also worked and I only had to set the correct library path to get it working!
So in essence:
To get swift compile on FreeBSD follow the instructions on:
change bootstrapping mode in configure.sh to off:
-DBOOTSTRAPPING_MODE=OFF \
and everything compiles
What version of Swift did you build?
I tried to build with release/5.8
branches following the instructions, but I got the following errors:
$ ninja
...
[4304/4413] Compiling /home/kebo/swift/build/tools/swift/stdlib/public/Platform//FREEBSD/x86_64/Glibc.o
FAILED: tools/swift/stdlib/public/Platform/FREEBSD/x86_64/Glibc.o /home/kebo/swift/build/tools/swift/stdlib/public/Platform/FREEBSD/x86_64/Glibc.o
cd /home/kebo/swift/build/tools/swift/stdlib/public/Platform && /usr/local/bin/python3 /usr/home/kebo/swift/swift/utils/line-directive @/home/kebo/swift/build/tools/swift/stdlib/public/Platform/8d867dd6b1ec09232628ee2ec417609030768a85.txt -- /home/kebo/swift/build/./bin/swiftc -c -sdk / -target x86_64-unknown-freebsd13.2 -resource-dir /home/kebo/swift/build/./lib/swift -O -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -D SWIFT_THREADING_PTHREADS -tools-directory /home/kebo/swift/build/bin -module-cache-path /home/kebo/swift/build/./module-cache -no-link-objc-runtime -enable-library-evolution -library-level api -Xfrontend -require-explicit-availability=ignore -Xfrontend -enforce-exclusivity=unchecked -D SWIFT_ENABLE_REFLECTION -module-name Glibc -swift-version 5 -swift-version 5 -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -Xfrontend -disable-autolinking-runtime-compatibility-concurrency -warn-swift3-objc-inference-complete -Xfrontend -disable-objc-interop -DSWIFT_ENABLE_REFLECTION -warn-implicit-overrides -Xfrontend -enable-ossa-modules -Xfrontend -enable-lexical-lifetimes=false -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -Xfrontend -disable-implicit-string-processing-module-import -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 9999:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.0:macOS\ 10.14.4,\ iOS\ 12.2,\ watchOS\ 5.2,\ tvOS\ 12.2 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.1:macOS\ 10.15,\ iOS\ 13.0,\ watchOS\ 6.0,\ tvOS\ 13.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.2:macOS\ 10.15.4,\ iOS\ 13.4,\ watchOS\ 6.2,\ tvOS\ 13.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.3:macOS\ 11.0,\ iOS\ 14.0,\ watchOS\ 7.0,\ tvOS\ 14.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.4:macOS\ 11.3,\ iOS\ 14.5,\ watchOS\ 7.4,\ tvOS\ 14.5 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.5:macOS\ 12.0,\ iOS\ 15.0,\ watchOS\ 8.0,\ tvOS\ 15.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.6:macOS\ 12.3,\ iOS\ 15.4,\ watchOS\ 8.5,\ tvOS\ 15.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.7:macOS\ 13.0,\ iOS\ 16.0,\ watchOS\ 9.0,\ tvOS\ 16.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.8:macOS\ 13.3,\ iOS\ 16.4,\ watchOS\ 9.4,\ tvOS\ 16.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.9:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -target-min-inlining-version -Xfrontend min -module-link-name swiftGlibc -whole-module-optimization -parse-as-library -resource-dir /home/kebo/swift/build/./lib/swift -I /home/kebo/swift/build/./lib/swift/freebsd -o /home/kebo/swift/build/tools/swift/stdlib/public/Platform//FREEBSD/x86_64/Glibc.o @/home/kebo/swift/build/tools/swift/stdlib/public/Platform/8d867dd6b1ec09232628ee2ec417609030768a85.txt
<unknown>:0: warning: glibc not found for 'x86_64-unknown-freebsd13.2'; C stdlib may be unavailable
/usr/home/kebo/swift/swift/stdlib/public/Platform/Glibc.swift.gyb:13:19: error: no such module 'SwiftGlibc'
@_exported import SwiftGlibc // Clang module
^
[4305/4413] Generating /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftmodule
FAILED: lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftmodule lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftdoc lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftinterface /home/kebo/swift/build/lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftmodule /home/kebo/swift/build/lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftdoc /home/kebo/swift/build/lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftinterface
cd /home/kebo/swift/build/tools/swift/stdlib/public/Platform && /usr/local/bin/cmake -E remove -f /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftmodule /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftdoc /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftinterface && /usr/local/bin/cmake -E make_directory /home/kebo/swift/build/./lib/swift/freebsd /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule && /usr/local/bin/python3 /usr/home/kebo/swift/swift/utils/line-directive @/home/kebo/swift/build/tools/swift/stdlib/public/Platform/8d867dd6b1ec09232628ee2ec417609030768a85.txt -- /home/kebo/swift/build/./bin/swiftc -emit-module -o /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftmodule -avoid-emit-module-source-info -sdk / -target x86_64-unknown-freebsd13.2 -resource-dir /home/kebo/swift/build/./lib/swift -O -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -D SWIFT_THREADING_PTHREADS -tools-directory /home/kebo/swift/build/bin -module-cache-path /home/kebo/swift/build/./module-cache -no-link-objc-runtime -enable-library-evolution -library-level api -Xfrontend -require-explicit-availability=ignore -Xfrontend -enforce-exclusivity=unchecked -D SWIFT_ENABLE_REFLECTION -module-name Glibc -swift-version 5 -swift-version 5 -autolink-force-load -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -Xfrontend -disable-autolinking-runtime-compatibility-concurrency -warn-swift3-objc-inference-complete -Xfrontend -disable-objc-interop -DSWIFT_ENABLE_REFLECTION -warn-implicit-overrides -Xfrontend -enable-ossa-modules -Xfrontend -enable-lexical-lifetimes=false -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -Xfrontend -disable-implicit-string-processing-module-import -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 9999:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.0:macOS\ 10.14.4,\ iOS\ 12.2,\ watchOS\ 5.2,\ tvOS\ 12.2 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.1:macOS\ 10.15,\ iOS\ 13.0,\ watchOS\ 6.0,\ tvOS\ 13.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.2:macOS\ 10.15.4,\ iOS\ 13.4,\ watchOS\ 6.2,\ tvOS\ 13.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.3:macOS\ 11.0,\ iOS\ 14.0,\ watchOS\ 7.0,\ tvOS\ 14.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.4:macOS\ 11.3,\ iOS\ 14.5,\ watchOS\ 7.4,\ tvOS\ 14.5 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.5:macOS\ 12.0,\ iOS\ 15.0,\ watchOS\ 8.0,\ tvOS\ 15.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.6:macOS\ 12.3,\ iOS\ 15.4,\ watchOS\ 8.5,\ tvOS\ 15.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.7:macOS\ 13.0,\ iOS\ 16.0,\ watchOS\ 9.0,\ tvOS\ 16.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.8:macOS\ 13.3,\ iOS\ 16.4,\ watchOS\ 9.4,\ tvOS\ 16.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.9:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -target-min-inlining-version -Xfrontend min -module-link-name swiftGlibc -whole-module-optimization -parse-as-library -resource-dir /home/kebo/swift/build/./lib/swift -I /home/kebo/swift/build/./lib/swift/freebsd -emit-module-interface-path /home/kebo/swift/build/./lib/swift/freebsd/Glibc.swiftmodule/x86_64-unknown-freebsd13.2.swiftinterface -Xfrontend -experimental-skip-non-inlinable-function-bodies @/home/kebo/swift/build/tools/swift/stdlib/public/Platform/8d867dd6b1ec09232628ee2ec417609030768a85.txt
<unknown>:0: warning: glibc not found for 'x86_64-unknown-freebsd13.2'; C stdlib may be unavailable
/usr/home/kebo/swift/swift/stdlib/public/Platform/Glibc.swift.gyb:13:19: error: no such module 'SwiftGlibc'
@_exported import SwiftGlibc // Clang module
^
[4306/4413] Compiling /home/kebo/swift/build/tools/swift/stdlib/public/Cxx//FREEBSD/x86_64/Cxx.o
<unknown>:0: warning: glibc not found for 'x86_64-unknown-freebsd13.2'; C stdlib may be unavailable
[4307/4413] Compiling /home/kebo/swift/build/tools/swift/stdlib/public/SwiftOnoneSupport//FREEBSD/x86_64/SwiftOnoneSupport.o
<unknown>:0: warning: glibc not found for 'x86_64-unknown-freebsd13.2'; C stdlib may be unavailable
[4308/4413] Compiling /home/kebo/swift/build/tools/swift/stdlib/public/core//FREEBSD/x86_64/Swift.o
<unknown>:0: warning: glibc not found for 'x86_64-unknown-freebsd13.2'; C stdlib may be unavailable
/home/kebo/swift/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Decodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
^
/home/kebo/swift/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Encodable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
^
/home/kebo/swift/swift/stdlib/public/core/SIMDVector.swift:63:17: warning: protocol 'SIMDScalar' should be declared to refine 'Hashable' due to a same-type constraint on 'Self'
public protocol SIMDScalar {
^
ninja: build stopped: subcommand failed.
I used head of the current branch.
Thank you. I think my errors may be resolved by this PR so I'll try with head or release/5.9 branches.
Updated: I also succeeded to build Swift on FreeBSD. I used release/5.9
branches.
With a freshly created jail on 13.2 I do the following
mkdir swift && cd swift
git clone -b main --depth=1 https://github.com/apple/swift
git clone -b stable/20221013 --depth=1 https://github.com/apple/llvm-project
git clone -b gfm --depth=1 https://github.com/apple/swift-cmark cmark
git clone -b main --depth=1 https://github.com/apple/swift-syntax
git clone -b main --depth=1 https://github.com/apple/swift-experimental-string-processing.git
mkdir build
cd build
../../configure.sh
with the configure.sh script containing:
#!/bin/sh
SRCROOT="`pwd`/.."
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_EXTERNAL_PROJECTS="cmark;swift" \
-DLLVM_EXTERNAL_CMARK_SOURCE_DIR="${SRCROOT}/cmark" \
-DLLVM_EXTERNAL_SWIFT_SOURCE_DIR="${SRCROOT}/swift" \
-DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="${SRCROOT}/swift-syntax" \
-DSWIFT_ENABLE_DISPATCH=OFF \
-DSWIFT_IMPLICIT_CONCURRENCY_IMPORT=OFF \
-DSWIFT_USE_LINKER=ld \
-DSWIFT_BUILD_STATIC_STDLIB=ON \
-DBOOTSTRAPPING_MODE=OFF \
-DSWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=ON \
-DSWIFT_PATH_TO_STRING_PROCESSING_SOURCE="${SRCROOT}/swift-experimental-string-processing" \
-G Ninja \
../llvm-project/llvm
then
cd swift/build
ninja
I got swift to build.