nodejs: fix cross compilation for non-emulatable platforms#384413
nodejs: fix cross compilation for non-emulatable platforms#384413rhelmot merged 1 commit intoNixOS:stagingfrom
Conversation
b1815b2 to
c40aa72
Compare
pkgs/development/web/nodejs/v22.nix
Outdated
There was a problem hiding this comment.
For non-upstreamable patches, I think it makes more sense to vendor them in the repo rather than fetching them
There was a problem hiding this comment.
I think it makes more sense for us to use another distro's patches if we're not super clear on the patch's long term situation because we can refer back to the other distro in order to see how they adjust the patch moving forward. If you think this is a silly/counterproductive/antisocial/etc argument I will gladly vendor it though!
aduh95
left a comment
There was a problem hiding this comment.
I haven't tested the cross compilation, but the change LGTM
|
An additional data point: I finally deployed a real application (immich) with node built cross for FreeBSD, and it works perfectly. There are some more patches coming in a separate PR for npm stuff, but it is definitely working without issue. |
This was tested x86_64-linux -> x86_64-freebsd. It works by injecting the tools that would otherwise be run at build time for the same executables extracted from a native build. Without this, there are multiple issues: a) It will fail to start building since there are naming conflicts between the "host" (build system) and "normal" (host system) object files. This is resolved with a patch from buildroot. b) It will then still fail to build since it will still try to build the "host" objects, with a host compiler, but it will use the configuration flags for the "target" OS. This is resolved by importing the executables that would otherwise be run on the build system from the intermediate stage of a native build, saved in a new "dev" output. We also fake the "host" compiler as a tool which simply touches its outputs. c) Finally, there is a clang bug which causes a static assert that something is trivially copyable to fire as a false positive. We remove this check with a patch from rubyjs.
This was tested x86_64-linux -> x86_64-freebsd. It works by injecting the tools that would otherwise be run at build time for the same executables extracted from a native build.
Without this, there are multiple issues:
a) It will fail to start building since there are naming conflicts
between the "host" (build system) and "normal" (host system) object
files. This is resolved with a patch from buildroot.
b) It will then still fail to build since it will still try to build the
"host" objects, with a host compiler, but it will use the
configuration flags for the "target" OS. This is resolved by
importing the executables that would otherwise be run on the build
system from the intermediate stage of a native build, saved in a new
"dev" output. We also fake the "host" compiler as a tool which simply
touches its outputs.
c) Finally, there is a clang bug which causes a static assert that
something is trivially copyable to fire as a false positive. We
remove this check with a patch from rubyjs.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.