Skip to content

Is there a distributed statically linked version of node? #58042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
coffeebe4code opened this issue Apr 26, 2025 · 8 comments
Closed

Is there a distributed statically linked version of node? #58042

coffeebe4code opened this issue Apr 26, 2025 · 8 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@coffeebe4code
Copy link

What is the problem this feature will solve?

I'm curious if there is already a distributed version of node by this team which is statically compiled for some target triples?

I've seen the build commands which can do so, but I'm trying to upstream to your other repo nodejs/docker-node a statically compiled version into docker images. But in order to obviously trust the source, it would have to come from this repository and be distributed.

Thank you

What is the feature you are proposing to solve the problem?

this feature would allow that. It would also close this.
node-runtime request

What alternatives have you considered?

none, too much bureaucracy otherwise. building a statically compiled version of node for docker is greatly wanted, but doing so not by this repository and distibuted, would never get ported to docker-node repository maintained by nodejs

@coffeebe4code coffeebe4code added the feature request Issues that request new features to be added to Node.js. label Apr 26, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Apr 26, 2025
@aduh95
Copy link
Contributor

aduh95 commented Apr 27, 2025

/cc @nodejs/build

@joyeecheung
Copy link
Member

See https://github.com/nodejs/unofficial-builds/ (unsure if the musl build there is fully statically linked)

@sylwek78

This comment was marked as off-topic.

@Flarna
Copy link
Member

Flarna commented Apr 28, 2025

I'm not sure but I think there were statically linked versions available/used in the past.
Main problem with them was that statically linked binaries can't load so files and as a result no native addons. This might be fine for some users but not all.

@coffeebe4code
Copy link
Author

I'm not sure but I think there were statically linked versions available/used in the past. Main problem with them was that statically linked binaries can't load so files and as a result no native addons. This might be fine for some users but not all.

I'd be curious to see how this is done, and why it couldn't load dynamically linked libraries. It should be theoretically possible with some work.

If you are saying the docker image would only have node statically linked with no OS, yes you would need to have a linker/loader embedded in node for that to work. A better proposal to support native addons would be to have a node-runtime be statically linked with your linux flavor OS still as the base.

The real problem with docker-node is that there is no "runtime", it all has npm, yarn and is used both as a build and runtime layer.

@Flarna
Copy link
Member

Flarna commented Apr 29, 2025

To my understanding a fully static linked binary doesn't include the dynamic loader and therefore it can't load shared objects - like native addons.

The node binaries used in current official docker images are not fully static linked.

A few moments ago, before the official node-docker images exists there were inofficial ones. There were a static linked version showing the problem I described. see mhart/alpine-node#75

@mhdawson
Copy link
Member

The Node.js binaries shipped on Nodejs.org include all of the dependencies but I don't believe they include components like gblic if that is what you meant.

@bnoordhuis
Copy link
Member

To my understanding a fully static linked binary doesn't include the dynamic loader and therefore it can't load shared objects - like native addons.

Another reason is that add-ons would use a different copy of libc (unless node linked in all of libc and re-exported it with --whole-archive) so even simple stuff like malloc/free would break.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
Archived in project
Development

No branches or pull requests

7 participants