Stream: beginners

Topic: Roc on OpenBSD


view this post on Zulip removewingman (Aug 02 2026 at 18:04):

I am trying to use roc on OpenBSD. I am trying to build the latest release from source, with (llvm-21.1.8p4 (installed)).
copyimagetmp.avif
Seems like an zig error tho? Idk, I specified -Dllvm-path=/usr/local
I am going to upgrade to OpenBSD snapshot and try with zig as system binary, maybe this will work. (did not work, got the same error)

view this post on Zulip Richard Feldman (Aug 03 2026 at 03:08):

@removewingman we actually did not have BSD support previously, but I just landed a PR to add it - can you give it a shot on current main?

view this post on Zulip removewingman (Aug 03 2026 at 19:26):

@Richard Feldman tried it on latest commit, command: zig build build-release -Dcompiler-version=nightly-2026-08-03-72b60af7cf -Dllvm-path=/usr/local
and with:

llvm-21.1.8p6 (installed)
llvm-22.1.8p3 (installed)

Got a lot of: error: unable to find static system library 'lldMinGW' using strategy 'mode_first'.
Full log:
log.txt

view this post on Zulip Richard Feldman (Aug 03 2026 at 19:31):

ok seems like we'll need to get a BSD machine set up so we aren't flying blind - @Luke Boswell is working on that :smile:

view this post on Zulip Will Hawkins (Aug 03 2026 at 19:44):

I have such a VM and I am trying to compile now!

view this post on Zulip Will Hawkins (Aug 03 2026 at 20:21):

I started the compile. I am on FreeBSD 15.1 (FreeBSD 15.1-RELEASE). I will keep you posted. (Slight restart because I installed the wrong version of zig!)

view this post on Zulip Luke Boswell (Aug 03 2026 at 21:34):

Ive started... but Im very slow with my bsd foo. I almost managed to get the right version of Zig running yesterday, but got distracted by roc-ray

view this post on Zulip Will Hawkins (Aug 03 2026 at 22:44):

FYI: I think that the problem is

  1. A call to llvm-config that fails and
  2. Odd/wrong versions of llvm installed (by default?).

I am getting really close.

view this post on Zulip removewingman (Aug 03 2026 at 22:59):

Would it be possible for now, to add OpenBSD and other BSDs as Cross Compilation Targets?

Something like this should be right: .{ .name = "x64openbsd", .query = .{ .cpu_arch = .x86_64, .os_tag = .openbsd, .abi = .none } },

view this post on Zulip Richard Feldman (Aug 03 2026 at 23:15):

yep! I'll make a PR :thumbs_up:

view this post on Zulip Richard Feldman (Aug 03 2026 at 23:33):

https://github.com/roc-lang/roc/pull/10591

view this post on Zulip removewingman (Aug 03 2026 at 23:39):

I can test OpenBSD as soon as: https://github.com/roc-lang/roc/pull/10582 (Alpine Linux fix) is merged and included.

view this post on Zulip Will Hawkins (Aug 03 2026 at 23:40):

I think that I found the last little problem.

view this post on Zulip Luke Boswell (Aug 04 2026 at 01:08):

For e2e platform support, I'd recommend using this platform and adding support for that target if you can build from source https://github.com/lukewilliamboswell/roc-platform-template-zig

view this post on Zulip Luke Boswell (Aug 04 2026 at 01:08):

If we get that working we're well on the way to basic-cli and others

view this post on Zulip Richard Feldman (Aug 04 2026 at 01:22):

@removewingman that PR landed btw, so cross compilation to BSD is now on main

view this post on Zulip removewingman (Aug 04 2026 at 01:30):

@Richard Feldman Nice, if you update, this one with main, I can try again (then it is in my Alpine Linux build): https://github.com/roc-lang/roc/pull/10582

view this post on Zulip Will Hawkins (Aug 04 2026 at 01:39):

Took a little longer than I wanted, but I have a compiled roc on FreeBSD.

view this post on Zulip Will Hawkins (Aug 04 2026 at 01:40):

The outstanding issue is solved right now with a workaround, but I will introduce a PR that explains the problem and contains at least a first-whack at a fix.

view this post on Zulip Richard Feldman (Aug 04 2026 at 01:49):

@removewingman https://github.com/roc-lang/roc/pull/10582 now has main merged in

view this post on Zulip removewingman (Aug 04 2026 at 02:16):

@Richard Feldman This is currently the branch default-platform-no-libc, got this:

copyimagetmp.avif

view this post on Zulip Luke Boswell (Aug 04 2026 at 02:19):

fyi if you roc version in your cli when you take a screenshot you can see the roc commit sha and thats helpful for confirming we are tracking the same source

view this post on Zulip removewingman (Aug 04 2026 at 02:21):

It actually does not, since I am building from source: Roc compiler version nightly-2026-August-04-main
https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/106329

(I should probably remove -Dcompiler-version in the build)

view this post on Zulip Luke Boswell (Aug 04 2026 at 02:22):

What does roc version give you instead? this is what I see

11:58:52 ~/Documents/Github/roc main$ roc version
Roc compiler version debug-5c51ae1c

view this post on Zulip Richard Feldman (Aug 04 2026 at 02:25):

I have a fix in progress btw, that was enough to go on :smile:

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:01):

ok it's gonna need a couple of PRs to fix

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:01):

one is in progress and another will be the fix for https://github.com/roc-lang/roc/issues/10598 on top of that one

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:04):

thanks for reporting all this @removewingman - we've never had any BSD, Alpine, or Celeron usage before, so this is shaking out a lot of issues! :sweat_smile:

view this post on Zulip Luke Boswell (Aug 04 2026 at 03:05):

Are you using Docker to repro the alpine issues Richard? how are you doing that?

view this post on Zulip removewingman (Aug 04 2026 at 03:06):

thanks for all the work, I know these thing are really small use and edge cases

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:24):

@Luke Boswell no, the thing about Alpine is just that it doesn't provide libc so you have to link musl (or equivalent) - so I'm not reproducing it, just following paths where we're assuming libc is available and it's not safe to assume that (e.g. passing -lc to lld when we shouldn't because libc isn't available)

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:24):

it's easy to get wrong because some operating systems require dynamically linking libc (e.g. macOS, Windows, openbsd)

view this post on Zulip Richard Feldman (Aug 04 2026 at 03:25):

so we have to pass it in the right circumstances and also not pass it in the right circumstances, including when compiling for the local machine vs cross-compiling for a different one :sweat_smile:

view this post on Zulip Will Hawkins (Aug 04 2026 at 05:46):

Richard Feldman said:

Luke Boswell no, the thing about Alpine is just that it doesn't provide libc so you have to link musl (or equivalent) - so I'm not reproducing it, just following paths where we're assuming libc is available and it's not safe to assume that (e.g. passing -lc to lld when we shouldn't because libc isn't available)

That's actually one of the problems with the FreeBSD compilation. The LLVM library that comes packaged with FreeBSD can call backtrace (https://man7.org/linux/man-pages/man3/backtrace.3.html) to build a backtrace. Unfortunately, FreeBSD's libc does not include that function -- it's in a separate library (named execinfo). So, my current fight is to get zig's build system to recognize that it is necessary to link execinfo even though it can't tell that it needs to (sorry about ending a sentence in a preposition). So, the build system keeps dropping my -lexecinfo because it doesn't see any symbols needed from it (but because LLVM's libraries rely on it, ... well, you get the idea).

view this post on Zulip removewingman (Aug 04 2026 at 11:22):

I tried the branch: https://github.com/roc-lang/roc/tree/issue-10598-bsd-default-platform
To crosscompile for FreeBSD and run (current release 15.1), file is for 12.0 tho:
copyimagetmp.avif

Also when compiling for NetBSD (current release 11.0), file is for 8.0 tho: main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for NetBSD 8.0, BuildID[sha1]=3d6d211fe5bdc18babbca620ded910862c585698, with debug_info, not stripped

If anyone wants to reproduce: https://codeberg.org/removewingman/qemu-setup

view this post on Zulip Will Hawkins (Aug 06 2026 at 19:07):

I am sorry that I have not yet had a chance to write up the notes that I made on compiling for FreeBSD and to pull together a PR with the necessary changes! I promise that I will get it done this evening!!


Last updated: Aug 12 2026 at 12:35 UTC