Swift Compilation on FreeBSD

I'm working on getting Swift compiling on FreeBSD. I'm not sure exactly what's going on, but I believe I've narrowed it down to the bottom of "swift/stdlib/public/SwiftShims/CMakeLists.txt". Essentially, the linking of "lib/swift/clang" is not happening. When I copy and paste the symlink command out of build.ninja, it's able to continue. What reason might there be that the produced ninja command isn't doing anything?

I'm not really too experienced with cmake or ninja, or I'd have figured this out by now. I've been working on it for awhile though...

How are you building? It could be the way that you are invoking build-script that is causing the dependency to be dropped.

Can you give some more info on your build system?
FreeBSD version, cpu archtype , swift version (branch) etc.

sorry, should have given more info. FreeBSD 12 release on AMD64, compiling swift 4.2. I think it may be compiler-related, but I'm not sure.

Just had at look at FreeBSD 12 and noticed some of the swift build dependancies don't seem to be available.
Do you have all of these installed?
git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev systemtap-sdt-dev tzdata rsync
If so, can you give me a list of the equivalent FreeBSD packages so I can install them.

Well, one of these is superfluous (libbsd), but almost all of them are available somewhere. I'm not sure what systemtap is, but it seems not to be. libblocksruntime comes with FreeBSD and doesn't need to be installed, but the rest are there from what I can see. The challenge can be figuring out what they're called, but they're there. Swift 3 definitely built on FreeBSD, so Swift 4 should be possible as well.

Here is a list of port names I've compiled. I believe this includes almost everything:

git cmake ninja clang python e2fsprogs-libuuid icu libedit libxml2 sqlite3 swig python ncurses pkg-config curl rsync

tzdata also seems to be a part of FreeBSD.

Although to install using pkg, the list seems to be:
git cmake ninja clang-devel python e2fsprogs-libuuid icu libedit libxml2 sqlite3 swig30 python ncurses pkgconf curl rsync

I usually compile everything via the ports tree though.

systemtap wont be needed for FreeBSD as dtrace is part of the system. I would say take a look at the output ninja -t deps ... and see why the dependency is missing.

Thanks for that, that helped me a bit. Here is the command which should be running, but isn't:
ninja -t commands|grep create_symlink|grep 'lib/swift/clang'

You run that in swift's build directory, and you can copy and paste the output back into the shell, and it just works, although I had to change the β€œ6.0.0” in the command to β€œ7.0.0”. Might be related.

There are other build errors after that, but that will be a discussion for another thread, if I can’t figure it out.

Having to change the command sounds like some value is getting set incorrectly. Because the value determines the path and it doesn't exist, the created link will probably be incorrect. I think you should figure out why it is using 6.0.0 (sounds like it may be using the wrong LLVM?)

Interestingly, I forced the build system to use 7.0.0 by temporarily moving clang into /usr/bin and while the command with β€œ6.0.0” was still being generated, it worked unmodified, yet the build process still came to a halt. Something definitely seems up with compiler selection. I’ll do some digging and let you know.

1 Like

Any updates on Freebsd release 12.1 which came out a month ago