biome icon indicating copy to clipboard operation
biome copied to clipboard

feat: support OpenBSD

Open neezer opened this issue 1 year ago • 11 comments

Use std::alloc::System for OpenBSD as jemalloc is not supported.

NOTE: I'm only 80% sure this works, as I was unable to finish compiling this on my OpenBSD laptop: I got all the way to 603/617 and then ran out of memory (my laptop is pretty ancient... like from 2012.) I'd love it if someone who has a beefier OpenBSD box could give this a spin.

TODO

  • [ ] Verify build completes on OpenBSD
  • [ ] Update GHA to build OpenBSD artifacts

closes #3672

neezer avatar Aug 23 '24 20:08 neezer

Since we're going to build it in GHA anyway, I think the PR should update the workflow to build it on openbsd. Not sure about support of openbsd in GitHub actions though.

nhedger avatar Aug 23 '24 21:08 nhedger

These might be worth looking into for CI, since bsd is not supported natively in github actions:

  • https://github.com/vmactions/openbsd-vm
  • https://github.com/cross-platform-actions/openbsd-builder

dyc3 avatar Aug 23 '24 21:08 dyc3

@nhedger Ok, I can take a stab at updating the GHA. Having not done this before, are there any guides about how I can test my changes locally? I found act and was trying that, but ...

act -W .github/workflows/release_cli.yml --container-architecture linux/amd64

... is failing on "Run Main Check version changes" and I'm not entirely sure why yet. 🤔

I checked CONTRIBUTING.md and I didn't see anything in there about making updates to GHA. Would appreciate any guidance you could throw my way. 😄 The links @dyc3 provided look very promising, at first glance.

neezer avatar Aug 23 '24 22:08 neezer

For testing new github actions, I would recommend testing them on your fork of the repo. You'll need to change the trigger condition so that it runs on push so that it runs when you push to your branch (perhaps on a different branch than this one, so we don't get pinged in our notifs when you push).

Once you are done, you can update this branch with the new actions and we can go from there.

dyc3 avatar Aug 23 '24 23:08 dyc3

For testing new github actions, I would recommend testing them on your fork of the repo.

Is that free for me to do? Or would I have to pay GitHub to run those?

neezer avatar Aug 23 '24 23:08 neezer

Yup, github runs all open source CI for free.

dyc3 avatar Aug 23 '24 23:08 dyc3

@dyc3 How would I verify if my changes work? I'm guessing I'd look for the uploaded artifact defined here but where would I find that, once the action completes?

neezer avatar Aug 23 '24 23:08 neezer

You'd check your repo's action runs: https://github.com/neezer/biome/actions to see if it succeeded. This appears to be your latest run: https://github.com/neezer/biome/actions/runs/10534020638/job/29191019446

dyc3 avatar Aug 24 '24 03:08 dyc3

@neezer are you still interested in this PR?

ematipico avatar Sep 19 '24 07:09 ematipico

@ematipico Yes, I'm blocked waiting for the ability to build OpenBSD snapshots in Github Actions, as that's the only way to get the required version of Rust available in a runner to build Biome... though at this rate, 7.6 will probably release soon, which might negate the (immediate) need for snapshots... unless y'all updated Biome to use a feature requiring Rust > v1.80.

neezer avatar Sep 19 '24 16:09 neezer

Once this is unblocked, another small patch is needed to make biome start and biome lsp-proxy work. OpenBSD does not provide a standard way to get the name of the currently running executable. To avoid std::env::current_exe being subtly broken, the rustc in ports is patched to always return an error value. I replaced the call in crates/biome_cli/src/service/unix.rs:59 with a hard-coded string (lazy), but I think using argv[0] either conditionally for OpenBSD or as a fallback on the error branch would work, since Command::new will search PATH for the correct executable if given just a name. There's also some tests that call current_exe which might need fixing too. Don't know how critical those are.

jbellerb avatar Mar 28 '25 02:03 jbellerb

@neezer any updates?

ematipico avatar Oct 06 '25 07:10 ematipico

I gave this a go, and it appears to have worked.

Instructions for building on OpenBSD 7.8 towards current main of biome:

git clone -o 'upstream' 'https://github.com/biomejs/biome' 'biome'
# Using git-pr requires installing git-extras.
# https://github.com/tj/git-extras/blob/main/Installation.md
git pr 'upstream:3707'
git checkout '@biomejs/[email protected]'
# The cherry-pick will result in a trivial conflict. Resolve it.
git cherry-pick pr/3707

# Apply @jbellerb's workaround:
sed -i.orig 's/^\( *let binary = \).*/\1"biome";/' \
    crates/biome_cli/src/service/unix.rs

# Having a beefy machine isn't necessarily enough. Building might
# exceed per-process resource limits. This seems to help:
ulimit -d unlimited; ulimit -l unlimited; ulimit -m unlimited

cargo build

Running printf 'foo\n\n' | ./target/debug/biome lsp-proxy returns:

Content-Length: 75

{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}

rymdbar avatar Oct 29 '25 09:10 rymdbar