feat: Add OpenBSD support for x64 and arm64 architectures#6163
Conversation
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
|
@claude is attempting to deploy a commit to the rollup-js Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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.
5369863 to
96b5453
Compare
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.
|
@lukastaegert Thanks! I tried again and updated. |
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.
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
|
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. |
|
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. |
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
openbsd-x64(x86_64-unknown-openbsd)openbsd-arm64(aarch64-unknown-openbsd)Files Modified
crosswithbuild-std: true@rollup/rollup-openbsd-x64and@rollup/rollup-openbsd-arm64Memory Allocator Configuration
Following the FreeBSD pattern and issue #6047:
local_dynamic_tls)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
local_dynamic_tlsfeature for thread-local storageBuild Process
cross-rs/crossfor cross-compilation-Zbuild-stdfor OpenBSD targets (no prebuilt stdlib)OpenBSD Considerations
local_dynamic_tlsfeature for proper thread-local storage on x64Related Issues
Test Plan
Breaking Changes
None. This is purely additive - adds new optional platform packages.
Notes