From e29c3309399b7d7ef8f606c300cd973da40012f2 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 8 Jul 2023 04:34:48 +0300 Subject: [PATCH] nodejs: use fetchpatch for cross-compilation patches --- .../web/nodejs/common-gypi-cross.patch | 84 ------------------- pkgs/development/web/nodejs/cross-patches.nix | 10 +++ pkgs/development/web/nodejs/v18.nix | 4 +- pkgs/development/web/nodejs/v20.nix | 4 +- 4 files changed, 14 insertions(+), 88 deletions(-) delete mode 100644 pkgs/development/web/nodejs/common-gypi-cross.patch create mode 100644 pkgs/development/web/nodejs/cross-patches.nix diff --git a/pkgs/development/web/nodejs/common-gypi-cross.patch b/pkgs/development/web/nodejs/common-gypi-cross.patch deleted file mode 100644 index 00bc7d7d2feb..000000000000 --- a/pkgs/development/web/nodejs/common-gypi-cross.patch +++ /dev/null @@ -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' ], diff --git a/pkgs/development/web/nodejs/cross-patches.nix b/pkgs/development/web/nodejs/cross-patches.nix new file mode 100644 index 000000000000..f6169db6f549 --- /dev/null +++ b/pkgs/development/web/nodejs/cross-patches.nix @@ -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="; + }) +] diff --git a/pkgs/development/web/nodejs/v18.nix b/pkgs/development/web/nodejs/v18.nix index 622a1fcdbc2c..9af08413fcaf 100644 --- a/pkgs/development/web/nodejs/v18.nix +++ b/pkgs/development/web/nodejs/v18.nix @@ -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; } diff --git a/pkgs/development/web/nodejs/v20.nix b/pkgs/development/web/nodejs/v20.nix index 52e8ff76bbb8..83113140a8f3 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -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; }