roc-toolkit icon indicating copy to clipboard operation
roc-toolkit copied to clipboard

FreeBSD port

Open gavv opened this issue 5 years ago • 5 comments

Last revised: Oct 2023

Add support for FreeBSD and probably other BSDs.

Some preliminary work is already done: #284 (see discussion).

In SConstruct, we already have generic unix platform (automatically used on non-linux and non-darwin posix) and generic cc compiler (to be used with POSIX-compatible C compilers other than gcc and clang). When these platform and compiler are used, no linux- or gcc/clang-specific code or options are used. However, so far they were actually tested only on Linux.

First we should try to build Roc on FreeBSD using unix --platfrom and gcc or clang --compiler. If it doesn't work out of the box, we should fix the issues by either editing the portable part of the code (e.g. in under target_posix directory) or creating new OS-specific target directories if necessary. See #292 for details on the porting process and this page for details on target directories.

We should also try to add FreeBSD to CI. Ideally, using qemu. If it wont work well, we can try to cross-compile to freebsd from Linux without running tests.

We should also update docs:

  • https://roc-streaming.org/toolkit/docs/portability/supported_platforms.html
  • https://roc-streaming.org/toolkit/docs/development/continuous_integration.html

gavv avatar May 23 '20 15:05 gavv

I've been able to compile and test the devel branch in a FreeNAS jail (11.5, FreeBSD 11.3-RELEASE-p6), although there were a few issues. After building, I was able to successfully roc-send a wav file from the FreeNAS to a remote linux host. Did have to pull in sox from the FreeBSD Ports tree to send a wave file, as sox is not in the main package repo.

  • The SConstruct struggled to find the correct toolchain to build with - I have clang 8 but llvm 9 installed, and scons wouldn't accept that. My setup might be non-standard, however.
  • IN_MULTICAST and MSG_DONTWAIT requires __BSD_VISIBLE to be defined, M_PI requires __BSD_VISIBLE or __XSI_VISIBLE, and struct sigaction and related requires _POSIX_SOURCE, __POSIX_VISIBLE, and __XSI_VISIBLE. There's probably some meta-flag that can be defined to set these correctly for the entire build, will see if I can find out what that might be.

Edit: the defines issue is related to _POSIX_C_SOURCE: like with darwin, it appears that macro should not be defined for FreeBSD.

jdeblese avatar Oct 19 '21 02:10 jdeblese

@jdeblese Great news! May I ask if you consider sending a patch? Right now I don't have a bsd machine at hand, so I kind of don't like to apply the changes blindly without being able to test them. But thanks for sharing anyway.

gavv avatar Oct 25 '21 16:10 gavv

The SConstruct struggled to find the correct toolchain to build with

Would be awesome if you could provide exact error messages or maybe even debug it a bit.

gavv avatar Oct 25 '21 16:10 gavv

Yes, I'll submit a PR to develop. Happy to experiment a bit more as well, and I may get a RPi set up with NetBSD or OpenBSD and test out compiling on there as well.

Re: scons, the exact error is problem detecting AR: found '/usr/local/bin/llvm-ar', which reports version 9.0.1, but expected version 8.0.0, which I fixed by replacing meta.compiler_ver with (9,0,1) at around line 525 in the calls to FindTool. Building in a new, clean jail had no such issue, so it is something specific to the jail that I first tried it in. I'm not familiar with FindTool, however, so I'm not sure I can debug that any further.

jdeblese avatar Oct 25 '21 20:10 jdeblese

Fresh master has some related changes in build system:

  • new generic unix platform, used when we're building for *nix that is not linux and darwin
  • new generic cc compiler, used when we're building for *nix and the compiler is not gcc and clang

gavv avatar Dec 25 '22 10:12 gavv