From 3751f6abb015d6141f33acd82ef7a55e76a02217 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Fri, 16 Jun 2023 08:55:13 +0300 Subject: nodejs_{18,20}: fix cross compilation from aarch64-linux This change adds a fix for Node.js build system passing flags intended for the target toolchain to the host toolchain. --- .../development/web/nodejs/common-gypi-cross.patch | 84 ++++++++++++++++++++++ pkgs/development/web/nodejs/v18.nix | 1 + pkgs/development/web/nodejs/v20.nix | 1 + 3 files changed, 86 insertions(+) create mode 100644 pkgs/development/web/nodejs/common-gypi-cross.patch (limited to 'pkgs/development') diff --git a/pkgs/development/web/nodejs/common-gypi-cross.patch b/pkgs/development/web/nodejs/common-gypi-cross.patch new file mode 100644 index 0000000000000..00bc7d7d2febe --- /dev/null +++ b/pkgs/development/web/nodejs/common-gypi-cross.patch @@ -0,0 +1,84 @@ +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/v18.nix b/pkgs/development/web/nodejs/v18.nix index 82117b1a64676..622a1fcdbc2c2 100644 --- a/pkgs/development/web/nodejs/v18.nix +++ b/pkgs/development/web/nodejs/v18.nix @@ -17,5 +17,6 @@ buildNodejs { ./revert-arm64-pointer-auth.patch ./node-npm-build-npm-package-logic.patch ./trap-handler-backport.patch + ./common-gypi-cross.patch ]; } diff --git a/pkgs/development/web/nodejs/v20.nix b/pkgs/development/web/nodejs/v20.nix index cfb90879c05df..52e8ff76bbb89 100644 --- a/pkgs/development/web/nodejs/v20.nix +++ b/pkgs/development/web/nodejs/v20.nix @@ -16,5 +16,6 @@ buildNodejs { ./disable-darwin-v8-system-instrumentation-node19.patch ./bypass-darwin-xcrun-node16.patch ./node-npm-build-npm-package-logic.patch + ./common-gypi-cross.patch ]; } -- cgit 1.4.1