Skip to content

Add rustc toolchain to alpine images#2488

Open
nikeee wants to merge 2 commits intonodejs:mainfrom
nikeee:fix/add-rust-cargo
Open

Add rustc toolchain to alpine images#2488
nikeee wants to merge 2 commits intonodejs:mainfrom
nikeee:fix/add-rust-cargo

Conversation

@nikeee
Copy link
Copy Markdown

@nikeee nikeee commented May 6, 2026

Description

Adds rustc and cargo. Uses host-native architecture, so should fix the below-mentioned issues for every arch except x64.

Node requires at least rust 1.82, which is available in alpine 3.22/3.23 (they currently ship 1.87).

Motivation and Context

Resolves #2486
Resolves #2487

Testing Details

See below

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • I have read the CONTRIBUTING.md document.

@nikeee nikeee force-pushed the fix/add-rust-cargo branch 6 times, most recently from 59e030f to f4f3919 Compare May 6, 2026 21:12
Ran `./update.sh 26 alpine3.22,alpine3.23`
@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 6, 2026

I'm currently unable to verify end-to-end that this fixes the issue as I'm getting a segfault after ~10 minutes when I try to build anything in this repository from source. But the warnings that it cannot find rustc/cargo are gone, so it will probably work. Might just run this through CI and see what happens.I don't think that it is related to the rust issue as it also happens on the main branch. Probably just my local broken docker instance.

Update:
Works:

/ # node
Welcome to Node.js v26.0.0.
Type ".help" for more information.
> Temporal
Object [Temporal] {}
> 
/ # uname -a
Linux 4da0360be3ae 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Wed Apr 22 16:06:43 UTC 2026 aarch64 Linux

@MikeMcC399
Copy link
Copy Markdown
Contributor

Is this necessary, given that nodejs/unofficial-builds#228 was merged?

@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 7, 2026

I think so, because x64-musl is pulled from the unofficial-builds while arm (and all other architectures) is built in this Dockerfile: 6027bae
It doesn't have a checksum, so I think there shouldn't be anything to download. It uses a platform-emulated arm build instead.

tldr: Still needed for #2487

@MikeMcC399
Copy link
Copy Markdown
Contributor

If we only consider the architectures in versions.json

      "alpine3.22": [
        "amd64",
        "arm64v8"
      ],
      "alpine3.23": [
        "amd64",
        "arm64v8"
      ],

then I guess #2476 would solve the build issue for arm64v8.

Let's wait for the amd64 build for Node.js 26.1.0 to be published first, then take it from there.

@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 7, 2026

Yeah, that's also a thing to consider. But I think since the backup source build should work too, we should add rust/cargo to it as well.

@nschonni
Copy link
Copy Markdown
Member

nschonni commented May 7, 2026

Alternately #2476 could address this, since then both the affected Alpine builds would be using the pre-built (that you fixed).
Otherwise, I think you need to run the full update.sh to include the changes in the other Alpine images

@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 7, 2026

Otherwise, I think you need to run the full update.sh to include the changes in the other Alpine images

Did that first but then undid the images for node < 26 because they don't need rust at this point in time as they don't ship temporal. Wouldn't hurt to have it there too, but isn't needed.

#2476 needs some additional work in the unofficial-builds repo that sets up cross-compilation for rust. I tried that initially, but that is significantly more work and error-prone than just updating the way how arm is built today. Doesn't mean that this shouldn't be done on the long run.

I think independent of #2476, rust has to be in the backup build for all other architectures regardless. But they don't matter that much.
Edit: This should also resolve #2487

@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 7, 2026

Added rust to the non-temporal builds in b257eed

@MikeMcC399
Copy link
Copy Markdown
Contributor

MikeMcC399 commented May 9, 2026

I don't think we should add rust & cargo to the toolchain here in this repo for Alpine, assuming that PR #2476 is adopted. This would build Docker images using the pre-built musl builds for amd64 and arm64 from https://unofficial-builds.nodejs.org

The landscape has changed from when Alpine was originally set up here.

  • s390x has been dropped
  • GitHub Actions offers a ubuntu-24.04-arm runner image, in addition to the ubuntu-24.04 image

This means it is now possible to run build tests for the two addressed architectures (amd64 & arm64) in Node.js 26 using GitHub Actions. (Earlier versions do however have other architectures attached, including also 32-bit.)

This is evolving technology, and Temporal was added at the very last minute for the release of Node.js 26.0.0, so we probably need some more discussions with each other whilst we work out the best way to address needs.

@MikeMcC399
Copy link
Copy Markdown
Contributor

I also noticed that the toolchain requirements are currently undocumented - see nodejs/node#63213

@MikeMcC399
Copy link
Copy Markdown
Contributor

This might also cause an issue with Node.js 22 builds which still include armv6, and there are no rust / cargo packages on Alpine for this architecture as far as I can tell.

https://pkgs.alpinelinux.org/packages

@nikeee
Copy link
Copy Markdown
Author

nikeee commented May 9, 2026

I don't think we should add rust & cargo to the toolchain here in this repo for Alpine, assuming that PR #2476 is adopted

Then #2487 would be invalid (it has been closed as a duplicate but the described issue still persists) and the other except arm/x86 would be broken. Honestly I don't see a point in installing gcc but no rust in a build process. We should probably just remove the entire fallback build in that case. Maybe @nschonni has a different opinion here.

Merging #2486 alone wouldn't solve the issue by its own because the unofficial-builds-repo is currently missing the cross-compilation infra for arm. Of course, it could be (and should probably be) done.

This might also cause an issue with Node.js 22 builds

Didn't include rust there at first but as requested added it in b257eed. We can revert this commit if that's an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Temporal API not available in Alpine v26 images Rust missing from build tools

3 participants