Swift on FreeBSD

For build-script options and arguments that you find work successfully, would you mind submitting a PR to build-presets.ini with a FreeBSD-specific preset so that it's easily reproducible?

3 Likes

I would not mind and looked at it , but I'm not proficient in how that ini file is used. I will have a look if I can figure out on how to change it, even though I only used the patch from @mhjacobson . He did all the work.

1 Like

I see that you use separate cmake and ninja invocations for building. Is there anything in build-script that prevents you from using it when building for FreeBSD? If not, you can just paste its arguments to a new section build-presets.ini, a preset is basically a sequence of newline-separate arguments to build-script with leading -- prefixes stripped off.

1 Like

@Max_Desiatov I just did follow these instructions and wanted to tell the others in this thread how one can now get it started building on current 13.2 FreeBSD.
I have no idea how those build systems work but I'll give it a try to find out how to add it to the 'normal' build system. Right now it's not really usable anyways as swift package manager is not included.

1 Like

Ok, I've tried out the utils/build-script as described in documentation and it started ok, but failed at one stage with _Float16 not being defined - even though the compiler switch explicitly seems to have use it:

[4252/4802][ 88%][6776.302s] Performing build step for 'compiler-rt'
[395/1097][ 36%][25.977s] Building C object lib/builtins/CMakeFiles/clang_rt.builtins-i386.dir/extendhfsf2.c.o
FAILED: lib/builtins/CMakeFiles/clang_rt.builtins-i386.dir/extendhfsf2.c.o
/root/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-freebsd-x86_64/./bin/clang -DVISIBILITY_HIDDEN  -Wall -Wno-unused-parameter -O2 -g -DNDEBUG -m32 -fno-lto -DCOMPILER_RT_HAS_FLOAT16 -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -MD -MT lib/builtins/CMakeFiles/clang_rt.builtins-i386.dir/extendhfsf2.c.o -MF lib/builtins/CMakeFiles/clang_rt.builtins-i386.dir/extendhfsf2.c.o.d -o lib/builtins/CMakeFiles/clang_rt.builtins-i386.dir/extendhfsf2.c.o -c /root/swift-project/llvm-project/compiler-rt/lib/builtins/extendhfsf2.c
In file included from /root/swift-project/llvm-project/compiler-rt/lib/builtins/extendhfsf2.c:11:
In file included from /root/swift-project/llvm-project/compiler-rt/lib/builtins/fp_extend_impl.inc:38:
/root/swift-project/llvm-project/compiler-rt/lib/builtins/fp_extend.h:44:9: error: _Float16 is not supported on this target
typedef _Float16 src_t;
        ^
1 error generated.

question would now be why -DCOMPILER_RT_HAS_FLOAT16 is used if though it has not ?
I'm not proficient in these things (I have stopped using manual build systems in the early 90's for a reason).
And it seems to takes ages before anything gets built ( 2 hours before that error happend) and just using /utils/update and building again this morning takes more than 20 minutes before it gets to that error again. Seems my freebsd server is too slow to for fixing this issue, neither have I any idea on how to proceed and where to look for - should one define float16 or fix the compiler define ?
I really hope that @mhjacobson gets to fixing these issues.

1 Like

You can rebuild incrementally with ninja which should be much faster, as described in the GettingStarted.md document.

2 Likes

The 20 Minutes was an incremental build with the few changes that utils/update fetched, but you are right a build without any changes will show that first error after a couple of seconds, even though it will continue doing stuff for another 200 seconds before the build script exits.
I'll have a look what I can do, but I have to get aquainted with that conglomerate of build system first.

1 Like

Looks like we are getting closer. I am looking forward to the day when I can run Vapor 4/Fluent 4 projects on FreeBSD.

5 Likes

Amazing guys! :raised_hands::raised_hands::raised_hands:

1 Like

What are the next steps toward getting a full release I can use to compile and run a Vapor app on FreeBSD? Just want to keep encouraging the work. :smiley:

3 Likes

This needs multiple patches merged before the Swift toolchain can be built successfully, here are a few that I know of:

2 Likes

How does this compare to the work Matt Jacobson has been doing? (Swift on FreeBSD — Matt Jacobson)

1 Like