nodejs: Fix build on arm64 hosts

When clang is used as cross compiler, it confuses gyp
system to enable -m64 option for host pieces of build
and the reason is that it assumes clang to be biarch
by default for all architectures but that maybe true for
x86/x86_64 combo but not true for arm/aarch64 systems

This is a backport from node 24

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2025-07-19 18:25:02 -07:00
parent 40ff27f5b3
commit d4c2a95d4f
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,133 @@
From 403264c02edc2689671dbefaf032e3acb4fb713d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= <targos@protonmail.com>
Date: Sat, 19 Apr 2025 12:22:10 +0200
Subject: [PATCH] build: remove redundant `-mXX` flags for V8
They are already set by `common.gypi`.
Needed to build on aarch64 build hosts with clang compiler
Drop it when upgrading to 0.24.x or newer.
Upstream-Status: Backport [https://github.com/nodejs/node/commit/403264c02edc2689671dbefaf032e3acb4fb713d]
PR-URL: https://github.com/nodejs/node/pull/57907
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
---
tools/v8_gypfiles/toolchain.gypi | 91 --------------------------------
1 file changed, 91 deletions(-)
Index: node-v22.16.0/tools/v8_gypfiles/toolchain.gypi
===================================================================
--- node-v22.16.0.orig/tools/v8_gypfiles/toolchain.gypi
+++ node-v22.16.0/tools/v8_gypfiles/toolchain.gypi
@@ -97,33 +97,6 @@
# Indicates if gcmole tools are downloaded by a hook.
'gcmole%': 0,
},
-
- # [GYP] this needs to be outside of the top level 'variables'
- 'conditions': [
- ['host_arch=="ia32" or host_arch=="x64" or \
- host_arch=="ppc" or host_arch=="ppc64" or \
- host_arch=="s390x" or \
- clang==1', {
- 'variables': {
- 'host_cxx_is_biarch%': 1,
- },
- }, {
- 'variables': {
- 'host_cxx_is_biarch%': 0,
- },
- }],
- ['target_arch=="ia32" or target_arch=="x64" or \
- target_arch=="ppc" or target_arch=="ppc64" or \
- target_arch=="s390x" or clang==1', {
- 'variables': {
- 'target_cxx_is_biarch%': 1,
- },
- }, {
- 'variables': {
- 'target_cxx_is_biarch%': 0,
- },
- }],
- ],
'target_defaults': {
'include_dirs': [
'<(V8_ROOT)',
@@ -553,71 +526,6 @@
'-mmmx', # Allows mmintrin.h for MMX intrinsics.
],
}],
- ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
- or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
- (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
- v8_target_arch=="ppc")', {
- 'target_conditions': [
- ['_toolset=="host"', {
- 'conditions': [
- ['host_cxx_is_biarch==1', {
- 'conditions': [
- ['host_arch=="s390x"', {
- 'cflags': [ '-m31' ],
- 'ldflags': [ '-m31' ]
- },{
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ]
- }],
- ],
- }],
- ],
- 'xcode_settings': {
- 'ARCHS': [ 'i386' ],
- },
- }],
- ['_toolset=="target"', {
- 'conditions': [
- ['target_cxx_is_biarch==1', {
- 'conditions': [
- ['host_arch=="s390x"', {
- 'cflags': [ '-m31' ],
- 'ldflags': [ '-m31' ]
- },{
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ],
- }],
- ],
- }],
- ],
- 'xcode_settings': {
- 'ARCHS': [ 'i386' ],
- },
- }],
- ],
- }],
- ['(OS=="linux" or OS=="android") and \
- (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
- v8_target_arch=="ppc64" or v8_target_arch=="s390x")', {
- 'target_conditions': [
- ['_toolset=="host"', {
- 'conditions': [
- ['host_cxx_is_biarch==1', {
- 'cflags': [ '-m64' ],
- 'ldflags': [ '-m64' ]
- }],
- ],
- }],
- ['_toolset=="target"', {
- 'conditions': [
- ['target_cxx_is_biarch==1', {
- 'cflags': [ '-m64' ],
- 'ldflags': [ '-m64' ],
- }],
- ]
- }],
- ],
- }],
['OS=="android" and v8_android_log_stdout==1', {
'defines': [
'V8_ANDROID_LOG_STDOUT',

View File

@ -30,6 +30,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \
file://0001-deps-disable-io_uring-support-in-libuv.patch \
file://0001-positional-args.patch \
file://0001-custom-env.patch \
file://0001-build-remove-redundant-mXX-flags-for-V8.patch \
file://run-ptest \
"
SRC_URI:append:class-target = " \