From d4c2a95d4fc5268e16896ff79c6a8a5c5604d6da Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 19 Jul 2025 18:25:02 -0700 Subject: 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 --- ...1-build-remove-redundant-mXX-flags-for-V8.patch | 133 +++++++++++++++++++++ meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb | 1 + 2 files changed, 134 insertions(+) create mode 100644 meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch new file mode 100644 index 0000000000..7841a9d7bc --- /dev/null +++ b/meta-oe/recipes-devtools/nodejs/nodejs/0001-build-remove-redundant-mXX-flags-for-V8.patch @@ -0,0 +1,133 @@ +From 403264c02edc2689671dbefaf032e3acb4fb713d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= +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 +Reviewed-By: Marco Ippolito +Reviewed-By: Chengzhong Wu +Reviewed-By: Rafael Gonzaga +Reviewed-By: Luigi Pinca +--- + 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', diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb index 4bc829f140..0663e8c52e 100644 --- a/meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb +++ b/meta-oe/recipes-devtools/nodejs/nodejs_22.16.0.bb @@ -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 = " \ -- cgit v1.2.3-54-g00ecf