Skip to content

Add support for FreeBSD (x64 and arm64)#5698

Merged
lukastaegert merged 27 commits intorollup:masterfrom
tagattie:freebsd-support
Oct 27, 2024
Merged

Add support for FreeBSD (x64 and arm64)#5698
lukastaegert merged 27 commits intorollup:masterfrom
tagattie:freebsd-support

Conversation

@tagattie
Copy link
Copy Markdown
Contributor

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

This PR contains a set of changes necessary for building and publishing native binary for FreeBSD (x64 and arm64). Changes include:

  • add build-freebsd job to GitHub Actions workflow
    • it is difficult to add a FreeBSD-related target to existing build job, so add a dedicated job
  • add npm directories for freebsd-x64 and freebsd-arm64 along with changes to native.js and package.json
  • make small changes for rust codes
    • freebsd-x64 requires local-dynamic-tls feature of mimalloc-rust crate

With those changes, npm run test:only finishes with the following output:

  5123 passing (2m)
  2 pending
  1 failing
  1) rollup
       cli
         watch
           watch-config-error: keeps watching the config file in case the config is changed to an invalid state:
     Error: Test aborted due to timeout.
      at /home/runner/work/rollup/rollup/test/cli/index.js:78:21
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

One failuer is apparently due to underlying chokidar module. A similar change to chokidar solves the error and makes all tests pass.

I would much appreciate it if this PR is considered for inclusion for future releases.

- Add FreeBSD entries in native.js and package.json
- Add directories for npm module
- Patch Cargo.toml and lib.rs to enable local-dynamic-tls for FreeBSD
It seems 4 is too many.
It appears the same trick as for Linux is necessary for FreeBSD.
It takes a long time, not convenient for test.
npm run ci:test:only exits with an error:
[!] RollupError: Could not resolve "../../wasm/bindings_wasm" from "browser/src/initWasm.ts"
Test on x86-64 finished almost successfully (with one error).
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2024 6:08am

Copy link
Copy Markdown
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Looks good to me. I would merge this and create a patch release so you can check if the published version actually works as intended. And thanks so much for the work you put into this!

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.01%. Comparing base (9048a4f) to head (afe1568).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/watch/fileWatcher.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5698      +/-   ##
==========================================
- Coverage   99.03%   99.01%   -0.02%     
==========================================
  Files         257      257              
  Lines        8044     8046       +2     
  Branches     1357     1358       +1     
==========================================
+ Hits         7966     7967       +1     
  Misses         52       52              
- Partials       26       27       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lukastaegert lukastaegert disabled auto-merge October 27, 2024 06:31
@lukastaegert lukastaegert merged commit b9ff676 into rollup:master Oct 27, 2024
@github-actions
Copy link
Copy Markdown

This PR has been released as part of rollup@4.24.1. You can test it via npm install rollup.

@lukastaegert
Copy link
Copy Markdown
Member

I overlooked that the ARM build really is abysmally slow. Not sure I would want to keep it this way, for instance when publishing, everything is waiting for this one job for 15-20 minutes (still counting). Maybe it can be made faster by running on an actual ARM platform? But I did not look into details. After all, the x86 build is quite fast.

@tagattie
Copy link
Copy Markdown
Contributor Author

Yes, FreeBSD arm64 build takes a long time (over 30-40 minutes) ☹️ It's because the action (cross-platform-actions/action) uses QEMU for emulating arm64 on x86-64 platform. If it is not acceptable for the project, I would be OK to make another PR to disable arm64 build for now.

The last part of the blog post says GitHub will provide arm64 runners for open source projects by the end of the year. So I hope we can build for arm64 much faster eventually.

@lukastaegert
Copy link
Copy Markdown
Member

But is it really necessary to use an arm64 platform to build for an arm64 platform? To my understanding, Rust is capable of cross-building to some degree?

@tagattie
Copy link
Copy Markdown
Contributor Author

Yes, rust is indeed capable of cross-building for some target platforms. But FreeBSD arm64 platform is not (yet) supported as the target. An output from rustup target list | grep freebsd on FreeBSD x86-64 is as follows:

$ rustup target list | grep freebsd
i686-unknown-freebsd
x86_64-unknown-freebsd (installed)

So we need a native platform for building an artifact for FreeBSD arm64 at the moment...

@lukastaegert
Copy link
Copy Markdown
Member

Ok, thanks for the info. So for the time being, maybe we stick with the current setup and see how annoying it is. And then let's hope that the Arm64 will really become available for Open Source eventually.

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 FreeBSD

2 participants