about summary refs log tree commit diff
path: root/pkgs/development/web
diff options
context:
space:
mode:
authorIvan Trubach <mr.trubach@icloud.com>2023-06-16 08:55:13 +0300
committerIvan Trubach <mr.trubach@icloud.com>2023-08-28 12:16:30 +0300
commit3751f6abb015d6141f33acd82ef7a55e76a02217 (patch)
treea5366d42564c49f123e4dae1aad5db7ac7d217e3 /pkgs/development/web
parentdeb5cc6dc8a300ef9d64252445329f288869440e (diff)
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.
Diffstat (limited to 'pkgs/development/web')
-rw-r--r--pkgs/development/web/nodejs/common-gypi-cross.patch84
-rw-r--r--pkgs/development/web/nodejs/v18.nix1
-rw-r--r--pkgs/development/web/nodejs/v20.nix1
3 files changed, 86 insertions, 0 deletions
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
   ];
 }