Add riscv64 (linux-gnu) prebuilt binary - #1268
Conversation
Add riscv64gc-unknown-linux-gnu to the napi build matrix, cross-compiled in the napi-rs lts-debian image with gcc-riscv64-linux-gnu, and register the riscv64 triple in scripts/build-npm.js so the lightningcss-linux-riscv64-gnu package is generated and added to optionalDependencies. The node loader already maps process.arch 'riscv64' to that package, so no loader change is needed. Validated: the cross-compiled .node is a riscv64gc ELF and runs on a SpacemiT K1 (Banana Pi F3); transform and minify smoke test passes. Signed-off-by: Bruno Verachten <gounthar@gmail.com>
|
I'm not sure this has wide enough usage to take on officially. We also have no way to test that it works. What hardware are you running this on? Can you just compile it from source? |
|
Hardware is a Banana Pi BPI-F3: SpaceMiT K1, 8 cores, Ubuntu 24.04, Node 20. A ~100 USD SBC, nothing exotic. On usage, that's fair, riscv64 npm traffic is small today. The one thing that makes it surface a bit more than the raw numbers suggest is that nobody installs lightningcss deliberately, it arrives through vite or tailwind v4. So a normal frontend project on one of these boards dies at require time on a missing optional dependency, and the error names lightningcss rather than the thing that pulled it in. You have the download numbers and I don't, so you're better placed than me to judge whether that's worth a matrix entry. Compiling from source does work, I did it: 53 minutes wall clock on the F3. The build isn't really the painful part, it's that the resulting .node has to be dropped into node_modules by hand after every install, in a package the user never chose. On testing, RISE runs a pool of native riscv64 GitHub Actions runners (label If the runner setup is the awkward part, I can introduce you to the RISE people who operate the pool and do the back and forth myself, so it stays off your plate. Their whole point is making riscv64 CI available to upstream projects. And if you'd rather not carry the target at all, no hard feelings, I'll keep it downstream. |
Adds
riscv64gc-unknown-linux-gnuto the release matrix so a prebuiltlightningcss-linux-riscv64-gnugets published, and lightningcss loads natively on riscv64 Linux instead of throwing at require time.Closes #1267.
Changes
.github/workflows/release.yml: new matrix entry on the existing napi-rslts-debianimage. It reuses the existingmatrix.setupstep to installgcc-riscv64-linux-gnu, strips withriscv64-linux-gnu-strip, and setsCARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKERon both build steps.scripts/build-npm.js: register theriscv64gc-unknown-linux-gnutriple (glibc) and mapriscv64gc -> riscv64.Verification
lightningcss.linux-riscv64-gnu.node(ELF 64-bit RISC-V) in about 3 minutes.require()loads it andtransform({...})minifies.a{ color: #ffffff }to.a{color:#fff}.I went with cross-compile to match the other targets rather than adding a native riscv64 runner to the matrix. Let me know if you'd prefer it done differently.