nodejs: use fetchpatch for cross-compilation patches

This commit is contained in:
Ivan Trubach 2023-07-08 04:34:48 +03:00
parent e4d6d1b05b
commit e29c330939
4 changed files with 14 additions and 88 deletions

View file

@ -1,84 +0,0 @@
Fixes target toolchain arguments being passed to the host toolchain when
cross-compiling. For example, -m64 is not available on aarch64.
diff --git a/common.gypi b/common.gypi
index 3161adbe09..08983f589c 100644
--- a/common.gypi
+++ b/common.gypi
@@ -411,28 +411,56 @@
'cflags': [ '-I/usr/local/include' ],
'ldflags': [ '-Wl,-z,wxneeded' ],
}],
- ],
- 'conditions': [
- [ 'target_arch=="ia32"', {
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ],
- }],
- [ 'target_arch=="x64"', {
- 'cflags': [ '-m64' ],
- 'ldflags': [ '-m64' ],
- }],
- [ 'target_arch=="ppc" and OS not in "aix os400"', {
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ],
- }],
- [ 'target_arch=="ppc64" and OS not in "aix os400"', {
- 'cflags': [ '-m64', '-mminimal-toc' ],
- 'ldflags': [ '-m64' ],
+ ['_toolset=="host"', {
+ 'conditions': [
+ [ 'host_arch=="ia32"', {
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ [ 'host_arch=="x64"', {
+ 'cflags': [ '-m64' ],
+ 'ldflags': [ '-m64' ],
+ }],
+ [ 'host_arch=="ppc" and OS not in "aix os400"', {
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ [ 'host_arch=="ppc64" and OS not in "aix os400"', {
+ 'cflags': [ '-m64', '-mminimal-toc' ],
+ 'ldflags': [ '-m64' ],
+ }],
+ [ 'host_arch=="s390x" and OS=="linux"', {
+ 'cflags': [ '-m64', '-march=z196' ],
+ 'ldflags': [ '-m64', '-march=z196' ],
+ }],
+ ],
}],
- [ 'target_arch=="s390x" and OS=="linux"', {
- 'cflags': [ '-m64', '-march=z196' ],
- 'ldflags': [ '-m64', '-march=z196' ],
+ ['_toolset=="target"', {
+ 'conditions': [
+ [ 'target_arch=="ia32"', {
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ [ 'target_arch=="x64"', {
+ 'cflags': [ '-m64' ],
+ 'ldflags': [ '-m64' ],
+ }],
+ [ 'target_arch=="ppc" and OS not in "aix os400"', {
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ [ 'target_arch=="ppc64" and OS not in "aix os400"', {
+ 'cflags': [ '-m64', '-mminimal-toc' ],
+ 'ldflags': [ '-m64' ],
+ }],
+ [ 'target_arch=="s390x" and OS=="linux"', {
+ 'cflags': [ '-m64', '-march=z196' ],
+ 'ldflags': [ '-m64', '-march=z196' ],
+ }],
+ ],
}],
+ ],
+ 'conditions': [
[ 'OS=="solaris"', {
'cflags': [ '-pthreads' ],
'ldflags': [ '-pthreads' ],

View file

@ -0,0 +1,10 @@
{ fetchpatch }:
[
# Fixes target toolchain arguments being passed to the host toolchain when
# cross-compiling. For example, -m64 is not available on aarch64.
(fetchpatch {
name = "common-gypi-cross.patch";
url = "https://github.com/nodejs/node/pull/48597.patch";
hash = "sha256-FmHmwlTxPw5mTW6t4zuy9vr4FxopjU4Kx+F1aqabG1s=";
})
]

View file

@ -6,6 +6,7 @@ let
python = python3;
};
crossPatches = callPackage ./cross-patches.nix { };
in
buildNodejs {
inherit enableNpm;
@ -17,6 +18,5 @@ buildNodejs {
./revert-arm64-pointer-auth.patch
./node-npm-build-npm-package-logic.patch
./trap-handler-backport.patch
./common-gypi-cross.patch
];
] ++ crossPatches;
}

View file

@ -6,6 +6,7 @@ let
python = python3;
};
crossPatches = callPackage ./cross-patches.nix { };
in
buildNodejs {
inherit enableNpm;
@ -16,6 +17,5 @@ buildNodejs {
./disable-darwin-v8-system-instrumentation-node19.patch
./bypass-darwin-xcrun-node16.patch
./node-npm-build-npm-package-logic.patch
./common-gypi-cross.patch
];
] ++ crossPatches;
}