nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.46k stars 29.01k forks source link

Option to have a shared V8 library? #53509

Open Ashvith10 opened 2 months ago

Ashvith10 commented 2 months ago

What is the problem this feature will solve?

In distros like NixOS and GuixSD, building NodeJS from scratch is a heavy computation. Building V8 seperately for NodeJS is not only computationally heavy, but it also makes caching the good parts of the library impossible for a simple failed test. It is painful having to wait for a day to have a package build, only for the tests to fail for the package maintainer to disable or patch them one by one per build.

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

With V8 as a shared library, it would be possible to not only cache the dependency in a functional package manager, but also use it with other packages that require them.

What alternatives have you considered?

None, as I've read somewhere than v8 dependencies are patched, which would make it impossible to use vanilla v8 alongside.

benjamingr commented 2 months ago

@nodejs/v8 this sounds like a good idea though probably not super practical due to the fact we float patches over v8

joyeecheung commented 2 months ago

If the need is to not have to rebuild V8, it seems the goal overlaps with the (very old) effort of linking Node.js with v8_monolith.a instead, but no one has been volunteering in making it work AFAIK. It just needs someone to wrestle with the gyp configs to figure out how to do it. Then it would become possible to cache the v8_monolith.a and reuse it in different Node.js builds that don't change anything in deps/v8.

bnoordhuis commented 2 weeks ago

but no one has been volunteering in making it work

/me raises hand

I plan on working on it, provided it can be done in a reasonable time frame. If anyone has concerns, now would be a good time to voice them.

Ashvith10 commented 1 week ago

@bnoordhuis are you still interested in working on this proposal? Or perhaps, could you give a few pointers so that I can try exploring this?

bnoordhuis commented 1 week ago

I haven't started yet so you're welcome to it. I'd start with the monolith build. Once that works, a shared library should be relatively easy.