Skip to content

feat: Add OpenBSD support for x64 and arm64 architectures#6163

Open
rpx99 wants to merge 12 commits into
rollup:masterfrom
rpx99:claude/add-openbsd-support-011CUqES9GgQZrmxvUN3r2tz
Open

feat: Add OpenBSD support for x64 and arm64 architectures#6163
rpx99 wants to merge 12 commits into
rollup:masterfrom
rpx99:claude/add-openbsd-support-011CUqES9GgQZrmxvUN3r2tz

Conversation

@rpx99

@rpx99 rpx99 commented Nov 5, 2025

Copy link
Copy Markdown

Summary

This PR adds native binary support for OpenBSD on both x64 and arm64 architectures, following the same patterns established for FreeBSD support.

Changes

Platform Support

  • ✅ Added openbsd-x64 (x86_64-unknown-openbsd)
  • ✅ Added openbsd-arm64 (aarch64-unknown-openbsd)

Files Modified

  1. native.js - Added OpenBSD platform detection
  2. package.json - Added OpenBSD build targets to napi.targets
  3. GitHub Actions - Added OpenBSD builds to CI matrix using cross with build-std: true
  4. Cargo.toml - Configured mimalloc dependencies for OpenBSD
  5. lib.rs - Excluded OpenBSD aarch64 from mimalloc (uses system allocator)
  6. npm packages - Created @rollup/rollup-openbsd-x64 and @rollup/rollup-openbsd-arm64

Memory Allocator Configuration

Following the FreeBSD pattern and issue #6047:

Platform Allocator Reason
OpenBSD x64 mimalloc (with local_dynamic_tls) Performance
OpenBSD arm64 System allocator Avoid SIGILL on older ARM64 CPUs

OpenBSD aarch64 is explicitly excluded from using mimalloc to prevent potential illegal instruction crashes on ARM64 processors that don't support armv8.1-a instruction set extensions.

Implementation Details

mimalloc Safety

  • OpenBSD x64 uses mimalloc with the local_dynamic_tls feature for thread-local storage
  • OpenBSD arm64 uses the system allocator (same as FreeBSD arm64)
  • This prevents SIGILL crashes on older/embedded ARM64 processors (ref: illegal instruction on android arm64 #6047)

Build Process

  • Uses GitHub Actions with cross-rs/cross for cross-compilation
  • Requires -Zbuild-std for OpenBSD targets (no prebuilt stdlib)
  • Identical configuration to FreeBSD builds (proven working since Add support for FreeBSD (x64 and arm64) #5698)

OpenBSD Considerations

  • ABI Stability: OpenBSD does not guarantee ABI compatibility between releases
  • pledge/unveil: No conflict - Rollup doesn't use these OpenBSD-specific syscalls
  • TLS: Uses local_dynamic_tls feature for proper thread-local storage on x64

Related Issues

Test Plan

  • CI builds complete successfully for both architectures
  • OpenBSD x64 binary runs on OpenBSD 7.x amd64
  • OpenBSD arm64 binary runs on OpenBSD 7.x arm64
  • Rollup can bundle a test project on both platforms
  • No SIGILL crashes on ARM64

Breaking Changes

None. This is purely additive - adds new optional platform packages.

Notes

  • OpenBSD binaries will need to be rebuilt for each OpenBSD major release due to ABI changes
  • This follows the exact same pattern as the successful FreeBSD implementation
  • Conservative approach: arm64 uses system allocator for maximum compatibility

This commit adds native binary support for OpenBSD, similar to the existing FreeBSD support.

Changes:
- Add OpenBSD platform detection to native.js
- Add OpenBSD build targets (x86_64-unknown-openbsd, aarch64-unknown-openbsd) to package.json
- Create npm packages for @rollup/rollup-openbsd-x64 and @rollup/rollup-openbsd-arm64
- Add OpenBSD build configurations to GitHub Actions CI workflow
- Update Cargo.toml to include OpenBSD in target-specific dependencies

Fixes rollup#5478
Related to rollup#5491
OpenBSD aarch64 should use the system allocator instead of mimalloc,
following the same pattern as FreeBSD aarch64. This prevents potential
SIGILL crashes on ARM64 processors that don't support armv8.1-a
instruction set extensions.

mimalloc assumes certain CPU features that may not be available on
all ARM64 implementations, particularly on embedded and older systems.
Using the system allocator is safer and more compatible.

Platform support:
- OpenBSD x64: Uses mimalloc with local_dynamic_tls
- OpenBSD arm64: Uses system allocator (no mimalloc)

Ref: rollup#5478
Ref: rollup#6047
@vercel

vercel Bot commented Nov 5, 2025

Copy link
Copy Markdown

@claude is attempting to deploy a commit to the rollup-js Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Nov 7, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rollup Ready Ready Preview Comment Nov 25, 2025 5:07am

@lukastaegert lukastaegert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Unfortunately, this does not seem to build out-of-the-box. Not sure if you can see the job logs, this is the failure

2025-11-07T16:14:33.139Z napi:build Start building crate: bindings_napi
2025-11-07T16:14:33.139Z napi:build   cargo build --target x86_64-unknown-openbsd --release -Zbuild-std=std,core,alloc,panic_unwind -Zbuild-std-features=panic-unwind
[cross] warning: `cross` does not provide a Docker image for target x86_64-unknown-openbsd, specify a custom image in `Cross.toml`.
[cross] error: Errors encountered before cross compilation, aborting.
[cross] note: Disable this with `CROSS_NO_WARNINGS=0`
Internal Error: Build failed with exit code 1
    at ChildProcess.<anonymous> (file:///home/runner/work/rollup/rollup/node_modules/@napi-rs/cli/dist/cli.js:1436:36)
    at Object.onceWrapper (node:events:623:26)
    at ChildProcess.emit (node:events:520:35)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)
Error: Process completed with exit code 1.

and similarly for aarch64-unknown-openbsd.

@lukastaegert lukastaegert force-pushed the master branch 2 times, most recently from 5369863 to 96b5453 Compare November 7, 2025 21:32
cross-rs does not support OpenBSD targets (only FreeBSD, NetBSD, DragonFly).
This commit creates a separate build-openbsd job that uses
cross-platform-actions/action to build natively on OpenBSD via QEMU.

Changes:
- Remove OpenBSD from main build matrix (cross doesn't support it)
- Add new build-openbsd job using cross-platform-actions/action v0.25.0
- Build on OpenBSD 7.6 for both x86-64 and arm64 architectures
- Install Rust nightly-2025-07-25 and build with -Zbuild-std
- Add build-openbsd to needs: dependencies in smoke-test, test, and publish jobs

This approach is similar to how FreeBSD was initially supported before
cross-rs added FreeBSD support.

Ref: rollup#5478
OpenBSD 7.8 is the current stable release.
Update build configuration to use 7.8 instead of 7.6.
@rpx99

rpx99 commented Nov 10, 2025

Copy link
Copy Markdown
Author

@lukastaegert Thanks! I tried again and updated.

claude and others added 4 commits November 20, 2025 20:11
This commit fixes multiple issues with the OpenBSD build:

1. Update cross-platform-actions from v0.25.0 to v0.30.0
   - v0.30.0 adds native support for OpenBSD 7.8
   - Fixes 404 errors when downloading resources

2. Fix sort-keys ESLint error in native.js
   - Move openbsd entry between linux and openharmony (alphabetical order)
   - Required by eslint sort-keys rule

3. Use native cargo build instead of npm run build:napi
   - Avoid cross-compilation issues and GLIBC errors
   - Build directly with cargo in OpenBSD VM
   - Automatically find and rename the built library file

The build now runs natively on OpenBSD 7.8 via QEMU without attempting
to use Linux build tools or cross-compilation.

Ref: rollup#5478
Improve the build script to properly find and copy the built library:
- Change directory back to root after cargo build
- Use find to locate the library file dynamically
- Add error handling if library is not found

This fixes path issues in the previous commit.
claude and others added 3 commits November 22, 2025 07:44
Align the build-openbsd job with other jobs in the workflow that
already use actions/checkout@v5.0.1 instead of v5.0.0.

This ensures consistency across all workflow jobs.
OpenBSD does not support rustup (error: unrecognized OS type: OpenBSD).
This commit switches to using OpenBSD's native Rust package via pkg_add.

Changes:
- Replace rustup installation with 'pkg_add rust'
- Remove nightly toolchain requirement (use stable Rust from OpenBSD)
- Temporarily override rust-toolchain.toml during build
- Remove -Zbuild-std flags (not needed for native builds)
- Add gcc and gmake dependencies for native compilation

OpenBSD packages provide a recent enough Rust version for building
the project, and the standard library is already available for the
native target.

Fixes the error:
  error: unrecognized OS type: OpenBSD

Ref: rollup#5478
Ref: rust-lang/rustup#2377
@lukastaegert

lukastaegert commented Jan 22, 2026

Copy link
Copy Markdown
Member

x64 support for OpenBSD has been implemented by now in #6224, not sure if you want to further pursue arm64 support. Otherwise, we should probably close this.

@ikmckenz

ikmckenz commented Mar 14, 2026

Copy link
Copy Markdown

I'm interested in arm64 support, perhaps I'll open a new PR for just arm since amd4 is already implemented.

Edit: Looks like #6247 already exists, just needs a small change.

@ikmckenz ikmckenz mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for OpenBSD/adJ

5 participants