From 74c663dd4ed728d956cf5f0000200bfc58e80366 Mon Sep 17 00:00:00 2001 From: Jason Schonberg Date: Sat, 23 May 2026 17:00:27 +1200 Subject: nodejs: upgrade 22.22.2 -> 22.22.3 With this upgrade, nodejs updated the llhttp dependency to version 9.3.1 So some of the patches are nolonger necessary. Changelog: https://github.com/nodejs/node/releases/tag/v22.22.3 Signed-off-by: Jason Schonberg Signed-off-by: Khem Raj (cherry picked from commit ea56a5e3ae463a1b9d28298f47f27b40e519ca6d) Signed-off-by: Ankur Tyagi Signed-off-by: Anuj Mittal --- .../0001-detect-aarch64-Neon-correctly.patch | 51 ----- .../0001-fix-arm-Neon-intrinsics-types.patch | 59 ------ ...NEON-header-value-__builtin_ctzll-undefin.patch | 60 ------ meta-oe/recipes-devtools/nodejs/nodejs_22.22.2.bb | 224 --------------------- meta-oe/recipes-devtools/nodejs/nodejs_22.22.3.bb | 221 ++++++++++++++++++++ 5 files changed, 221 insertions(+), 394 deletions(-) delete mode 100644 meta-oe/recipes-devtools/nodejs/nodejs/0001-detect-aarch64-Neon-correctly.patch delete mode 100644 meta-oe/recipes-devtools/nodejs/nodejs/0001-fix-arm-Neon-intrinsics-types.patch delete mode 100644 meta-oe/recipes-devtools/nodejs/nodejs/0001-llhttp-fix-NEON-header-value-__builtin_ctzll-undefin.patch delete mode 100644 meta-oe/recipes-devtools/nodejs/nodejs_22.22.2.bb create mode 100644 meta-oe/recipes-devtools/nodejs/nodejs_22.22.3.bb diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0001-detect-aarch64-Neon-correctly.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0001-detect-aarch64-Neon-correctly.patch deleted file mode 100644 index 15de2c1119..0000000000 --- a/meta-oe/recipes-devtools/nodejs/nodejs/0001-detect-aarch64-Neon-correctly.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 41ec2d5302b77be27ca972102c29ce12471ed4b0 Mon Sep 17 00:00:00 2001 -From: Gyorgy Sarvari -Date: Thu, 12 Feb 2026 11:09:44 +0100 -Subject: [PATCH 2/2] detect aarch64 Neon correctly - -The llhttp vendored dependency of nodejs takes advantage of Arm NEON -instructions when they are available, however they are detected by -checking for an outdated CPU feature macro: it checks for __ARM_NEON__, -however it is not defined by new compilers for aarch64, rather they -set __ARM_NEON. The Arm C extension guide[1] refers to __ARM_NEON macro -aswell. - -This patch changes the detection to check for both macros when detecting -the availability of NEON instructions. - -The code this patch modifies is generated, so the patch itself isn't -suitable for upstream submission, as the root cause of the error is -in the generator itself. A PR has been submitted[2] to the generator -project to rectify this issue. - -[1]: https://developer.arm.com/documentation/ihi0053/d/ - pdf, section 6.9 -[2]: https://github.com/nodejs/llparse/pull/84 - -Upstream-Status: Inappropriate [see above] -Signed-off-by: Gyorgy Sarvari ---- - deps/llhttp/src/llhttp.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/deps/llhttp/src/llhttp.c b/deps/llhttp/src/llhttp.c -index a0e59e50..b069bbbb 100644 ---- a/deps/llhttp/src/llhttp.c -+++ b/deps/llhttp/src/llhttp.c -@@ -10,7 +10,7 @@ - #endif /* _MSC_VER */ - #endif /* __SSE4_2__ */ - --#ifdef __ARM_NEON__ -+#if defined(__ARM_NEON__) || defined(__ARM_NEON) - #include - #endif /* __ARM_NEON__ */ - -@@ -2625,7 +2625,7 @@ static llparse_state_t llhttp__internal__run( - goto s_n_llhttp__internal__n_header_value_otherwise; - } - #endif /* __SSE4_2__ */ -- #ifdef __ARM_NEON__ -+ #if defined(__ARM_NEON__) || defined(__ARM_NEON) - while (endp - p >= 16) { - uint8x16_t input; - uint8x16_t single; diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0001-fix-arm-Neon-intrinsics-types.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0001-fix-arm-Neon-intrinsics-types.patch deleted file mode 100644 index ddbad575f0..0000000000 --- a/meta-oe/recipes-devtools/nodejs/nodejs/0001-fix-arm-Neon-intrinsics-types.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 3f4283dac7d88a89b42f1f2966a862cee5afe486 Mon Sep 17 00:00:00 2001 -From: Gyorgy Sarvari -Date: Thu, 12 Feb 2026 11:03:53 +0100 -Subject: [PATCH 1/2] fix arm Neon intrinsics types - -The current code calls these intrinsics with incorrect datatypes -(it uses a vector of uint16 instead of uint8), causing compilation -to fail with the following error: - -| ../deps/llhttp/src/llhttp.c: In function 'llhttp__internal__run': -| ../deps/llhttp/src/llhttp.c:2645:9: note: use '-flax-vector-conversions' to permit conversions between vectors with differing element types or numbers of subparts -| 2645 | ); -| | ^ -| ../deps/llhttp/src/llhttp.c:2643:11: error: incompatible type for argument 1 of 'vandq_u16' -| 2643 | vcgeq_u8(input, vdupq_n_u8(' ')), - -To avoid this, set the correct intrinsics call that matches the -actual arguments. - -The code that this patch modifies is generated code, so in itself -this change isn't appropriate for upstream. The actual problem -is in the code generator itself, for which a PR is already pending -for merging[1]. This patch is a port of that PR. - -[1]: https://github.com/nodejs/llparse/pull/79 - -Upstream-Status: Inappropriate [see above] -Signed-off-by: Gyorgy Sarvari ---- - deps/llhttp/src/llhttp.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/deps/llhttp/src/llhttp.c b/deps/llhttp/src/llhttp.c -index aa4c4682..887603fd 100644 ---- a/deps/llhttp/src/llhttp.c -+++ b/deps/llhttp/src/llhttp.c -@@ -2639,17 +2639,17 @@ static llparse_state_t llhttp__internal__run( - /* Find first character that does not match `ranges` */ - single = vceqq_u8(input, vdupq_n_u8(0x9)); - mask = single; -- single = vandq_u16( -+ single = vandq_u8( - vcgeq_u8(input, vdupq_n_u8(' ')), - vcleq_u8(input, vdupq_n_u8('~')) - ); -- mask = vorrq_u16(mask, single); -- single = vandq_u16( -+ mask = vorrq_u8(mask, single); -+ single = vandq_u8( - vcgeq_u8(input, vdupq_n_u8(0x80)), - vcleq_u8(input, vdupq_n_u8(0xff)) - ); -- mask = vorrq_u16(mask, single); -- narrow = vshrn_n_u16(mask, 4); -+ mask = vorrq_u8(mask, single); -+ narrow = vshrn_n_u16(vreinterpretq_u16_u8(mask), 4); - match_mask = ~vget_lane_u64(vreinterpret_u64_u8(narrow), 0); - match_len = __builtin_ctzll(match_mask) >> 2; - if (match_len != 16) { diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0001-llhttp-fix-NEON-header-value-__builtin_ctzll-undefin.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0001-llhttp-fix-NEON-header-value-__builtin_ctzll-undefin.patch deleted file mode 100644 index 683dddcf04..0000000000 --- a/meta-oe/recipes-devtools/nodejs/nodejs/0001-llhttp-fix-NEON-header-value-__builtin_ctzll-undefin.patch +++ /dev/null @@ -1,60 +0,0 @@ -From a63a5faea54055973bf5f0a514444532563cc20d Mon Sep 17 00:00:00 2001 -From: Telukula Jeevan Kumar Sahu -Date: Fri, 27 Feb 2026 20:58:43 +0530 -Subject: [PATCH] llhttp: fix NEON header value __builtin_ctzll undefined - behavior - -When all 16 bytes match the allowed range, match_mask becomes 0 after -the bitwise NOT. Calling __builtin_ctzll(0) is undefined behavior per -the C standard. - -The code expects match_len == 16 when all bytes match (so the branch -is skipped and p += 16 continues the loop), but this relied on -ctzll(0) returning 64, which is not guaranteed. - -GCC at -O2 exploits this UB by deducing that __builtin_ctzll() result -is always in range [0, 63], and after >> 2 always in [0, 15], which -is never equal to 16. The compiler then optimizes -"if (match_len != 16)" to always-true, causing every valid 16-byte -chunk to be falsely rejected as containing an invalid character. - -This manifests as HTTP 400 Bad Request (HPE_INVALID_HEADER_TOKEN) for -any HTTP header value longer than 16 characters on ARM targets with -NEON enabled. - -Fix by explicitly checking for match_mask == 0 and setting -match_len = 16, avoiding the undefined behavior entirely. This bug -affects both aarch64 and armv7 NEON targets. - -The fix has been merged upstream in llparse 7.3.1 [1] and is included -in llhttp 9.3.1. This patch can be dropped when nodejs updates its -bundled llhttp to >= 9.3.1. - -[1]: https://github.com/nodejs/llparse/pull/83 - -Upstream-Status: Inappropriate -Signed-off-by: Telukula Jeevan Kumar Sahu ---- - deps/llhttp/src/llhttp.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/deps/llhttp/src/llhttp.c b/deps/llhttp/src/llhttp.c -index 14b731e..b0a46c6 100644 ---- a/deps/llhttp/src/llhttp.c -+++ b/deps/llhttp/src/llhttp.c -@@ -2651,7 +2651,11 @@ static llparse_state_t llhttp__internal__run( - mask = vorrq_u8(mask, single); - narrow = vshrn_n_u16(vreinterpretq_u16_u8(mask), 4); - match_mask = ~vget_lane_u64(vreinterpret_u64_u8(narrow), 0); -- match_len = __builtin_ctzll(match_mask) >> 2; -+ if (match_mask == 0) { -+ match_len = 16; -+ } else { -+ match_len = __builtin_ctzll(match_mask) >> 2; -+ } - if (match_len != 16) { - p += match_len; - goto s_n_llhttp__internal__n_header_value_otherwise; --- -2.34.1 - diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.2.bb b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.2.bb deleted file mode 100644 index 3a1385f70a..0000000000 --- a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.2.bb +++ /dev/null @@ -1,224 +0,0 @@ -DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" -HOMEPAGE = "http://nodejs.org" -LICENSE = "MIT & ISC & BSD-2-Clause & BSD-3-Clause & Artistic-2.0 & Apache-2.0 & BlueOak-1.0.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=b195f4ea4368177a2fd84b879f09cba8" - -CVE_PRODUCT = "nodejs node.js" - -DEPENDS = "openssl openssl-native file-replacement-native python3-packaging-native" -DEPENDS:append:class-target = " qemu-native" -DEPENDS:append:class-native = " c-ares-native" - -inherit pkgconfig python3native qemu ptest siteinfo - -COMPATIBLE_MACHINE:armv4 = "(!.*armv4).*" -COMPATIBLE_MACHINE:armv5 = "(!.*armv5).*" -COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*" - -COMPATIBLE_HOST:riscv64 = "null" -COMPATIBLE_HOST:riscv32 = "null" -COMPATIBLE_HOST:powerpc = "null" -COMPATIBLE_HOST:powerpc64le = "null" - -SRC_URI = "https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ - file://0001-Do-not-use-glob-in-deps.patch \ - file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ - file://0004-v8-don-t-override-ARM-CFLAGS.patch \ - file://system-c-ares.patch \ - file://0001-liftoff-Correct-function-signatures.patch \ - file://libatomic.patch \ - 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://0001-fix-arm-Neon-intrinsics-types.patch \ - file://0001-detect-aarch64-Neon-correctly.patch \ - file://0001-llhttp-fix-NEON-header-value-__builtin_ctzll-undefin.patch \ - file://run-ptest \ - " -SRC_URI:append:class-target = " \ - file://0001-Using-native-binaries.patch \ - " -SRC_URI:append:toolchain-clang:powerpc64le = " \ - file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \ - " -SRC_URI[sha256sum] = "b6bedd3a8cacd5df7df015a5088264b12c74a277ba60684cb9642ae8eb743132" - -S = "${UNPACKDIR}/node-v${PV}" - -# v8 errors out if you have set CCACHE -CCACHE = "" - -def map_nodejs_arch(a, d): - import re - - if re.match('i.86$', a): return 'ia32' - elif re.match('x86_64$', a): return 'x64' - elif re.match('aarch64$', a): return 'arm64' - elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64' - elif re.match('powerpc$', a): return 'ppc' - return a - -ARCHFLAGS:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ - ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ - bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ - bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ - '--with-arm-fpu=vfp', d), d), d)}" -ARCHFLAGS:append:mips = " --v8-lite-mode" -ARCHFLAGS:append:mipsel = " --v8-lite-mode" -ARCHFLAGS ?= "" - -PACKAGECONFIG ??= "ares brotli icu zlib" - -PACKAGECONFIG[ares] = "--shared-cares,,c-ares c-ares-native" -PACKAGECONFIG[brotli] = "--shared-brotli,,brotli brotli-native" -PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu icu-native" -PACKAGECONFIG[libuv] = "--shared-libuv,,libuv libuv-native" -PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2 nghttp2-native" -PACKAGECONFIG[shared] = "--shared" -PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" - -EXTRANATIVEPATH += "file-native" - -python prune_sources() { - import shutil - - shutil.rmtree(d.getVar('S') + '/deps/openssl') - if 'ares' in d.getVar('PACKAGECONFIG'): - shutil.rmtree(d.getVar('S') + '/deps/cares') - if 'brotli' in d.getVar('PACKAGECONFIG'): - shutil.rmtree(d.getVar('S') + '/deps/brotli') - if 'libuv' in d.getVar('PACKAGECONFIG'): - shutil.rmtree(d.getVar('S') + '/deps/uv') - if 'nghttp2' in d.getVar('PACKAGECONFIG'): - shutil.rmtree(d.getVar('S') + '/deps/nghttp2') - if 'zlib' in d.getVar('PACKAGECONFIG'): - shutil.rmtree(d.getVar('S') + '/deps/zlib') -} -do_patch[postfuncs] += "prune_sources" - -# V8's JIT infrastructure requires binaries such as mksnapshot and -# mkpeephole to be run in the host during the build. However, these -# binaries must have the same bit-width as the target (e.g. a x86_64 -# host targeting ARMv6 needs to produce a 32-bit binary). -# 1. If host and target have the different bit width, run those -# binaries for the target and run them on the host with QEMU. -# 2. If host and target have the same bit width, enable upstream -# cross compile support and no QEMU -python do_create_v8_qemu_wrapper () { - """Creates a small wrapper that invokes QEMU to run some target V8 binaries - on the host.""" - qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'), - d.expand('${STAGING_DIR_HOST}${base_libdir}')] - qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'), - qemu_libdirs) - - if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1": - qemu_cmd = "" - - wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh') - with open(wrapper_path, 'w') as wrapper_file: - wrapper_file.write("""#!/bin/sh - -# This file has been generated automatically. -# It invokes QEMU to run binaries built for the target in the host during the -# build process. - -%s "$@" -""" % qemu_cmd) - os.chmod(wrapper_path, 0o755) -} - -do_create_v8_qemu_wrapper[dirs] = "${B}" -addtask create_v8_qemu_wrapper after do_configure before do_compile - -export CC_host -export CFLAGS_host -export CXX_host -export CXXFLAGS_host -export LDFLAGS_host -export AR_host -export HOST_AND_TARGET_SAME_WIDTH - -CROSS_FLAGS = "--cross-compiling" -CROSS_FLAGS:class-native = "--no-cross-compiling" - -# Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi -do_configure () { - GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES - # $TARGET_ARCH settings don't match --dest-cpu settings - python3 configure.py --verbose --prefix=${prefix} \ - --shared-openssl \ - --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ - --dest-os=linux \ - --libdir=${baselib} \ - ${CROSS_FLAGS} \ - ${ARCHFLAGS} \ - ${PACKAGECONFIG_CONFARGS} -} - -do_compile () { - install -D ${RECIPE_SYSROOT_NATIVE}/etc/ssl/openssl.cnf ${B}/deps/openssl/nodejs-openssl.cnf - install -D ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh - oe_runmake BUILDTYPE=Release -} - -do_install () { - oe_runmake install DESTDIR=${D} -} - -do_install_ptest () { - cp -r ${B}/out/Release/cctest ${D}${PTEST_PATH}/ - cp -r ${B}/test ${D}${PTEST_PATH} - chown -R root:root ${D}${PTEST_PATH} -} - -PACKAGES =+ "${PN}-npm" -FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack" -RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \ - python3-misc python3-multiprocessing" - -PACKAGES =+ "${PN}-systemtap" -FILES:${PN}-systemtap = "${datadir}/systemtap" - -do_configure[prefuncs] += "set_gyp_variables" -do_compile[prefuncs] += "set_gyp_variables" -do_install[prefuncs] += "set_gyp_variables" -python set_gyp_variables () { - if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "0": - # We don't want to cross-compile during target compile, - # and we need to use the right flags during host compile, - # too. - d.setVar("CC_host", d.getVar("CC") + " -pie -fPIE") - d.setVar("CFLAGS_host", d.getVar("CFLAGS")) - d.setVar("CXX_host", d.getVar("CXX") + " -pie -fPIE") - d.setVar("CXXFLAGS_host", d.getVar("CXXFLAGS")) - d.setVar("LDFLAGS_host", d.getVar("LDFLAGS")) - d.setVar("AR_host", d.getVar("AR")) - elif d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1": - # Enable upstream cross compile support - d.setVar("CC_host", d.getVar("BUILD_CC")) - d.setVar("CFLAGS_host", d.getVar("BUILD_CFLAGS")) - d.setVar("CXX_host", d.getVar("BUILD_CXX")) - d.setVar("CXXFLAGS_host", d.getVar("BUILD_CXXFLAGS")) - d.setVar("LDFLAGS_host", d.getVar("BUILD_LDFLAGS")) - d.setVar("AR_host", d.getVar("BUILD_AR")) -} - -python __anonymous () { - # 32 bit target and 64 bit host (x86-64 or aarch64) have different bit width - if d.getVar("SITEINFO_BITS") == "32" and "64" in d.getVar("BUILD_ARCH"): - d.setVar("HOST_AND_TARGET_SAME_WIDTH", "0") - else: - d.setVar("HOST_AND_TARGET_SAME_WIDTH", "1") -} - -BBCLASSEXTEND = "native" - -CVE_STATUS[CVE-2026-21710] = "fixed-version: fixed since v22.22.2" -CVE_STATUS[CVE-2026-21712] = "cpe-incorrect: only v24 and v25 are affected" -CVE_STATUS[CVE-2026-21713] = "fixed-version: fixed since v22.22.2" -CVE_STATUS[CVE-2026-21714] = "fixed-version: fixed since v22.22.2" -CVE_STATUS[CVE-2026-21715] = "fixed-version: fixed since v22.22.2" -CVE_STATUS[CVE-2026-21716] = "fixed-version: fixed since v22.22.2" -CVE_STATUS[CVE-2026-21717] = "fixed-version: fixed since v22.22.2" diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_22.22.3.bb b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.3.bb new file mode 100644 index 0000000000..a13b71b762 --- /dev/null +++ b/meta-oe/recipes-devtools/nodejs/nodejs_22.22.3.bb @@ -0,0 +1,221 @@ +DESCRIPTION = "nodeJS Evented I/O for V8 JavaScript" +HOMEPAGE = "http://nodejs.org" +LICENSE = "MIT & ISC & BSD-2-Clause & BSD-3-Clause & Artistic-2.0 & Apache-2.0 & BlueOak-1.0.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=b195f4ea4368177a2fd84b879f09cba8" + +CVE_PRODUCT = "nodejs node.js" + +DEPENDS = "openssl openssl-native file-replacement-native python3-packaging-native" +DEPENDS:append:class-target = " qemu-native" +DEPENDS:append:class-native = " c-ares-native" + +inherit pkgconfig python3native qemu ptest siteinfo + +COMPATIBLE_MACHINE:armv4 = "(!.*armv4).*" +COMPATIBLE_MACHINE:armv5 = "(!.*armv5).*" +COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*" + +COMPATIBLE_HOST:riscv64 = "null" +COMPATIBLE_HOST:riscv32 = "null" +COMPATIBLE_HOST:powerpc = "null" +COMPATIBLE_HOST:powerpc64le = "null" + +SRC_URI = "https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ + file://0001-Do-not-use-glob-in-deps.patch \ + file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ + file://0004-v8-don-t-override-ARM-CFLAGS.patch \ + file://system-c-ares.patch \ + file://0001-liftoff-Correct-function-signatures.patch \ + file://libatomic.patch \ + 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 = " \ + file://0001-Using-native-binaries.patch \ + " +SRC_URI:append:toolchain-clang:powerpc64le = " \ + file://0001-ppc64-Do-not-use-mminimal-toc-with-clang.patch \ + " +SRC_URI[sha256sum] = "f3e6a578db1ab335a4a72785c1e87ad18a2cf6d2fc25747a1d741fb34af0bd0f" + +S = "${UNPACKDIR}/node-v${PV}" + +# v8 errors out if you have set CCACHE +CCACHE = "" + +def map_nodejs_arch(a, d): + import re + + if re.match('i.86$', a): return 'ia32' + elif re.match('x86_64$', a): return 'x64' + elif re.match('aarch64$', a): return 'arm64' + elif re.match('(powerpc64|powerpc64le|ppc64le)$', a): return 'ppc64' + elif re.match('powerpc$', a): return 'ppc' + return a + +ARCHFLAGS:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', '--with-arm-float-abi=hard', '--with-arm-float-abi=softfp', d)} \ + ${@bb.utils.contains('TUNE_FEATURES', 'neon', '--with-arm-fpu=neon', \ + bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', '--with-arm-fpu=vfpv3-d16', \ + bb.utils.contains('TUNE_FEATURES', 'vfpv3', '--with-arm-fpu=vfpv3', \ + '--with-arm-fpu=vfp', d), d), d)}" +ARCHFLAGS:append:mips = " --v8-lite-mode" +ARCHFLAGS:append:mipsel = " --v8-lite-mode" +ARCHFLAGS ?= "" + +PACKAGECONFIG ??= "ares brotli icu zlib" + +PACKAGECONFIG[ares] = "--shared-cares,,c-ares c-ares-native" +PACKAGECONFIG[brotli] = "--shared-brotli,,brotli brotli-native" +PACKAGECONFIG[icu] = "--with-intl=system-icu,--without-intl,icu icu-native" +PACKAGECONFIG[libuv] = "--shared-libuv,,libuv libuv-native" +PACKAGECONFIG[nghttp2] = "--shared-nghttp2,,nghttp2 nghttp2-native" +PACKAGECONFIG[shared] = "--shared" +PACKAGECONFIG[zlib] = "--shared-zlib,,zlib" + +EXTRANATIVEPATH += "file-native" + +python prune_sources() { + import shutil + + shutil.rmtree(d.getVar('S') + '/deps/openssl') + if 'ares' in d.getVar('PACKAGECONFIG'): + shutil.rmtree(d.getVar('S') + '/deps/cares') + if 'brotli' in d.getVar('PACKAGECONFIG'): + shutil.rmtree(d.getVar('S') + '/deps/brotli') + if 'libuv' in d.getVar('PACKAGECONFIG'): + shutil.rmtree(d.getVar('S') + '/deps/uv') + if 'nghttp2' in d.getVar('PACKAGECONFIG'): + shutil.rmtree(d.getVar('S') + '/deps/nghttp2') + if 'zlib' in d.getVar('PACKAGECONFIG'): + shutil.rmtree(d.getVar('S') + '/deps/zlib') +} +do_patch[postfuncs] += "prune_sources" + +# V8's JIT infrastructure requires binaries such as mksnapshot and +# mkpeephole to be run in the host during the build. However, these +# binaries must have the same bit-width as the target (e.g. a x86_64 +# host targeting ARMv6 needs to produce a 32-bit binary). +# 1. If host and target have the different bit width, run those +# binaries for the target and run them on the host with QEMU. +# 2. If host and target have the same bit width, enable upstream +# cross compile support and no QEMU +python do_create_v8_qemu_wrapper () { + """Creates a small wrapper that invokes QEMU to run some target V8 binaries + on the host.""" + qemu_libdirs = [d.expand('${STAGING_DIR_HOST}${libdir}'), + d.expand('${STAGING_DIR_HOST}${base_libdir}')] + qemu_cmd = qemu_wrapper_cmdline(d, d.getVar('STAGING_DIR_HOST'), + qemu_libdirs) + + if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1": + qemu_cmd = "" + + wrapper_path = d.expand('${B}/v8-qemu-wrapper.sh') + with open(wrapper_path, 'w') as wrapper_file: + wrapper_file.write("""#!/bin/sh + +# This file has been generated automatically. +# It invokes QEMU to run binaries built for the target in the host during the +# build process. + +%s "$@" +""" % qemu_cmd) + os.chmod(wrapper_path, 0o755) +} + +do_create_v8_qemu_wrapper[dirs] = "${B}" +addtask create_v8_qemu_wrapper after do_configure before do_compile + +export CC_host +export CFLAGS_host +export CXX_host +export CXXFLAGS_host +export LDFLAGS_host +export AR_host +export HOST_AND_TARGET_SAME_WIDTH + +CROSS_FLAGS = "--cross-compiling" +CROSS_FLAGS:class-native = "--no-cross-compiling" + +# Node is way too cool to use proper autotools, so we install two wrappers to forcefully inject proper arch cflags to workaround gypi +do_configure () { + GYP_DEFINES="${GYP_DEFINES}" export GYP_DEFINES + # $TARGET_ARCH settings don't match --dest-cpu settings + python3 configure.py --verbose --prefix=${prefix} \ + --shared-openssl \ + --dest-cpu="${@map_nodejs_arch(d.getVar('TARGET_ARCH'), d)}" \ + --dest-os=linux \ + --libdir=${baselib} \ + ${CROSS_FLAGS} \ + ${ARCHFLAGS} \ + ${PACKAGECONFIG_CONFARGS} +} + +do_compile () { + install -D ${RECIPE_SYSROOT_NATIVE}/etc/ssl/openssl.cnf ${B}/deps/openssl/nodejs-openssl.cnf + install -D ${B}/v8-qemu-wrapper.sh ${B}/out/Release/v8-qemu-wrapper.sh + oe_runmake BUILDTYPE=Release +} + +do_install () { + oe_runmake install DESTDIR=${D} +} + +do_install_ptest () { + cp -r ${B}/out/Release/cctest ${D}${PTEST_PATH}/ + cp -r ${B}/test ${D}${PTEST_PATH} + chown -R root:root ${D}${PTEST_PATH} +} + +PACKAGES =+ "${PN}-npm" +FILES:${PN}-npm = "${nonarch_libdir}/node_modules ${bindir}/npm ${bindir}/npx ${bindir}/corepack" +RDEPENDS:${PN}-npm = "bash python3-core python3-shell python3-datetime \ + python3-misc python3-multiprocessing" + +PACKAGES =+ "${PN}-systemtap" +FILES:${PN}-systemtap = "${datadir}/systemtap" + +do_configure[prefuncs] += "set_gyp_variables" +do_compile[prefuncs] += "set_gyp_variables" +do_install[prefuncs] += "set_gyp_variables" +python set_gyp_variables () { + if d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "0": + # We don't want to cross-compile during target compile, + # and we need to use the right flags during host compile, + # too. + d.setVar("CC_host", d.getVar("CC") + " -pie -fPIE") + d.setVar("CFLAGS_host", d.getVar("CFLAGS")) + d.setVar("CXX_host", d.getVar("CXX") + " -pie -fPIE") + d.setVar("CXXFLAGS_host", d.getVar("CXXFLAGS")) + d.setVar("LDFLAGS_host", d.getVar("LDFLAGS")) + d.setVar("AR_host", d.getVar("AR")) + elif d.getVar("HOST_AND_TARGET_SAME_WIDTH") == "1": + # Enable upstream cross compile support + d.setVar("CC_host", d.getVar("BUILD_CC")) + d.setVar("CFLAGS_host", d.getVar("BUILD_CFLAGS")) + d.setVar("CXX_host", d.getVar("BUILD_CXX")) + d.setVar("CXXFLAGS_host", d.getVar("BUILD_CXXFLAGS")) + d.setVar("LDFLAGS_host", d.getVar("BUILD_LDFLAGS")) + d.setVar("AR_host", d.getVar("BUILD_AR")) +} + +python __anonymous () { + # 32 bit target and 64 bit host (x86-64 or aarch64) have different bit width + if d.getVar("SITEINFO_BITS") == "32" and "64" in d.getVar("BUILD_ARCH"): + d.setVar("HOST_AND_TARGET_SAME_WIDTH", "0") + else: + d.setVar("HOST_AND_TARGET_SAME_WIDTH", "1") +} + +BBCLASSEXTEND = "native" + +CVE_STATUS[CVE-2026-21710] = "fixed-version: fixed since v22.22.2" +CVE_STATUS[CVE-2026-21712] = "cpe-incorrect: only v24 and v25 are affected" +CVE_STATUS[CVE-2026-21713] = "fixed-version: fixed since v22.22.2" +CVE_STATUS[CVE-2026-21714] = "fixed-version: fixed since v22.22.2" +CVE_STATUS[CVE-2026-21715] = "fixed-version: fixed since v22.22.2" +CVE_STATUS[CVE-2026-21716] = "fixed-version: fixed since v22.22.2" +CVE_STATUS[CVE-2026-21717] = "fixed-version: fixed since v22.22.2" -- cgit v1.2.3-54-g00ecf