From 5ca5a77660c478a4a6899cfd124b26c40cb2a3fc Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Sun, 5 May 2024 15:09:10 +0800 Subject: [PATCH] node: add v20.x LTS support --- lang/node/Makefile | 23 ++- lang/node/patches/v20.x/003-path.patch | 12 ++ .../node/patches/v20.x/004-musl_support.patch | 42 +++++ .../v20.x/007-fix_host_build_on_macos.patch | 11 ++ .../012-changing-default-npm-settings.patch | 20 +++ lang/node/patches/v20.x/200-uv_gyp.patch | 10 ++ lang/node/patches/v20.x/201-zlib_gyp.patch | 10 ++ lang/node/patches/v20.x/202-node_gyp.patch | 10 ++ .../patches/v20.x/203-icu-generic_gyp.patch | 106 ++++++++++++ lang/node/patches/v20.x/204-v8_gyp.patch | 158 ++++++++++++++++++ .../v20.x/999-localhost-no-addrconfig.patch | 29 ++++ ...able_pointer_authentication_on_arm64.patch | 10 ++ 12 files changed, 435 insertions(+), 6 deletions(-) create mode 100644 lang/node/patches/v20.x/003-path.patch create mode 100644 lang/node/patches/v20.x/004-musl_support.patch create mode 100644 lang/node/patches/v20.x/007-fix_host_build_on_macos.patch create mode 100644 lang/node/patches/v20.x/012-changing-default-npm-settings.patch create mode 100644 lang/node/patches/v20.x/200-uv_gyp.patch create mode 100644 lang/node/patches/v20.x/201-zlib_gyp.patch create mode 100644 lang/node/patches/v20.x/202-node_gyp.patch create mode 100644 lang/node/patches/v20.x/203-icu-generic_gyp.patch create mode 100644 lang/node/patches/v20.x/204-v8_gyp.patch create mode 100644 lang/node/patches/v20.x/999-localhost-no-addrconfig.patch create mode 100644 lang/node/patches/v20.x/999-revert_enable_pointer_authentication_on_arm64.patch diff --git a/lang/node/Makefile b/lang/node/Makefile index f2dac054..d26ccf38 100644 --- a/lang/node/Makefile +++ b/lang/node/Makefile @@ -6,6 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=node +ifeq ($(CONFIG_NODEJS_20),y) +PKG_VERSION:=v20.12.2 +PKG_RELEASE:=1 +PKG_HASH:=d7cbcc5fbfb31e9001f3f0150bbeda59abe5dd7137aaa6273958cd59ce35ced7 +PATCH_DIR:=./patches/v20.x +else ifeq ($(CONFIG_NODEJS_18),y) PKG_VERSION:=v18.15.0 PKG_RELEASE:=1 @@ -31,6 +37,7 @@ PATCH_DIR:=./patches/v12.x endif endif endif +endif PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://nodejs.org/dist/$(PKG_VERSION) @@ -59,7 +66,7 @@ define Package/node TITLE:=Node.js is a platform built on Chrome's JavaScript runtime URL:=https://nodejs.org/ DEPENDS:=@(HAS_FPU||KERNEL_MIPS_FPU_EMULATOR||SOFT_FLOAT) @!arc @!armeb @!powerpc \ - +libstdcpp +NODEJS_18:libopenssl +zlib +libnghttp2 +libuv \ + +libstdcpp +(NODEJS_18||NODEJS_20):libopenssl +zlib +libnghttp2 +libuv \ +libcares +libatomic +NODEJS_ICU_SYSTEM:icu +NODEJS_ICU_SYSTEM:icu-full-data endef @@ -94,25 +101,29 @@ define Package/node/config choice prompt "Version Selection" default NODEJS_12 if mips||mipsel||mips64||mips64el - default NODEJS_16 + default NODEJS_18 help Select node.js version. The host package version is also the same. config NODEJS_12 - bool "12.x Maintenance LTS" + bool "12.x End-of-life : Only for MIPS" config NODEJS_14 depends on !(mips||mipsel||mips64||mips64el) - bool "14.x Maintenance" + bool "14.x End-of-Life" config NODEJS_16 depends on !(mips||mipsel||mips64||mips64el) - bool "16.x Maintenance" + bool "16.x End-of-Life" config NODEJS_18 depends on !(mips||mipsel||mips64||mips64el) - bool "18.x Active LTS" + bool "18.x Maintenance LTS" + + config NODEJS_20 + depends on !(mips||mipsel||mips64||mips64el) + bool "20.x Active LTS" endchoice if PACKAGE_node diff --git a/lang/node/patches/v20.x/003-path.patch b/lang/node/patches/v20.x/003-path.patch new file mode 100644 index 00000000..02b45b6d --- /dev/null +++ b/lang/node/patches/v20.x/003-path.patch @@ -0,0 +1,12 @@ +--- a/lib/internal/modules/cjs/loader.js ++++ b/lib/internal/modules/cjs/loader.js +@@ -1529,7 +1529,8 @@ Module._initPaths = function() { + path.resolve(process.execPath, '..') : + path.resolve(process.execPath, '..', '..'); + +- const paths = [path.resolve(prefixDir, 'lib', 'node')]; ++ const paths = [path.resolve(prefixDir, 'lib', 'node'), ++ path.resolve(prefixDir, 'lib', 'node_modules')]; + + if (homeDir) { + ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries')); diff --git a/lang/node/patches/v20.x/004-musl_support.patch b/lang/node/patches/v20.x/004-musl_support.patch new file mode 100644 index 00000000..b0f95031 --- /dev/null +++ b/lang/node/patches/v20.x/004-musl_support.patch @@ -0,0 +1,42 @@ +--- a/deps/v8/src/base/platform/condition-variable.cc ++++ b/deps/v8/src/base/platform/condition-variable.cc +@@ -20,7 +20,7 @@ namespace base { + + ConditionVariable::ConditionVariable() { + #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \ +- (V8_OS_LINUX && V8_LIBC_GLIBC)) ++ V8_OS_LINUX) + // On Free/Net/OpenBSD and Linux with glibc we can change the time + // source for pthread_cond_timedwait() to use the monotonic clock. + pthread_condattr_t attr; +@@ -96,7 +96,7 @@ bool ConditionVariable::WaitFor(Mutex* m + &native_handle_, &mutex->native_handle(), &ts); + #else + #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \ +- (V8_OS_LINUX && V8_LIBC_GLIBC)) ++ V8_OS_LINUX) + // On Free/Net/OpenBSD and Linux with glibc we can change the time + // source for pthread_cond_timedwait() to use the monotonic clock. + result = clock_gettime(CLOCK_MONOTONIC, &ts); +--- a/deps/v8/src/base/platform/platform-posix.cc ++++ b/deps/v8/src/base/platform/platform-posix.cc +@@ -1147,7 +1147,7 @@ bool Thread::Start() { + #if V8_OS_DARWIN + // Default on Mac OS X is 512kB -- bump up to 1MB + stack_size = 1 * 1024 * 1024; +-#elif V8_OS_AIX ++#elif V8_OS_AIX || !defined(__GLIBC__) + // Default on AIX is 96kB -- bump up to 2MB + stack_size = 2 * 1024 * 1024; + #endif +--- a/deps/v8/src/codegen/external-reference-table.cc ++++ b/deps/v8/src/codegen/external-reference-table.cc +@@ -10,7 +10,7 @@ + #include "src/ic/stub-cache.h" + #include "src/logging/counters.h" + +-#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID) ++#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID) && defined(V8_LIBC_GLIBC) + #define SYMBOLIZE_FUNCTION + #include + diff --git a/lang/node/patches/v20.x/007-fix_host_build_on_macos.patch b/lang/node/patches/v20.x/007-fix_host_build_on_macos.patch new file mode 100644 index 00000000..b88c3147 --- /dev/null +++ b/lang/node/patches/v20.x/007-fix_host_build_on_macos.patch @@ -0,0 +1,11 @@ +--- a/tools/gyp/pylib/gyp/generator/make.py ++++ b/tools/gyp/pylib/gyp/generator/make.py +@@ -207,7 +207,7 @@ cmd_solink_module = $(LINK.$(TOOLSET)) - + + LINK_COMMANDS_MAC = """\ + quiet_cmd_alink = LIBTOOL-STATIC $@ +-cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) ++cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool /usr/bin/libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) + + quiet_cmd_link = LINK($(TOOLSET)) $@ + cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) diff --git a/lang/node/patches/v20.x/012-changing-default-npm-settings.patch b/lang/node/patches/v20.x/012-changing-default-npm-settings.patch new file mode 100644 index 00000000..6c735261 --- /dev/null +++ b/lang/node/patches/v20.x/012-changing-default-npm-settings.patch @@ -0,0 +1,20 @@ +--- a/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js ++++ b/deps/npm/node_modules/@npmcli/config/lib/definitions/definitions.js +@@ -1335,7 +1335,7 @@ define('lockfile-version', { + }) + + define('loglevel', { +- default: 'notice', ++ default: 'info', + type: [ + 'silent', + 'error', +@@ -2135,7 +2135,7 @@ define('strict-peer-deps', { + }) + + define('strict-ssl', { +- default: true, ++ default: false, + type: Boolean, + description: ` + Whether or not to do SSL key validation when making requests to the diff --git a/lang/node/patches/v20.x/200-uv_gyp.patch b/lang/node/patches/v20.x/200-uv_gyp.patch new file mode 100644 index 00000000..75bc8f2e --- /dev/null +++ b/lang/node/patches/v20.x/200-uv_gyp.patch @@ -0,0 +1,10 @@ +--- a/deps/uv/uv.gyp ++++ b/deps/uv/uv.gyp +@@ -155,6 +155,7 @@ + 'target_name': 'libuv', + 'toolsets': ['host', 'target'], + 'type': '<(uv_library)', ++ 'include_dirs!': [ ' +Last-Update: 2020-06-11 +Bug-Debian: https://bugs.debian.org/962318 +Forwarded: https://github.com/nodejs/node/issues/33816 +--- a/lib/net.js ++++ b/lib/net.js +@@ -1,4 +1,5 @@ + // Copyright Joyent, Inc. and other Node contributors. ++ + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the +@@ -1337,13 +1338,6 @@ function lookupAndConnect(self, options) + hints: options.hints || 0, + }; + +- if (!isWindows && +- dnsopts.family !== 4 && +- dnsopts.family !== 6 && +- dnsopts.hints === 0) { +- dnsopts.hints = dns.ADDRCONFIG; +- } +- + debug('connect: find host', host); + debug('connect: dns options', dnsopts); + self._host = host; diff --git a/lang/node/patches/v20.x/999-revert_enable_pointer_authentication_on_arm64.patch b/lang/node/patches/v20.x/999-revert_enable_pointer_authentication_on_arm64.patch new file mode 100644 index 00000000..bf8549c1 --- /dev/null +++ b/lang/node/patches/v20.x/999-revert_enable_pointer_authentication_on_arm64.patch @@ -0,0 +1,10 @@ +--- a/configure.py ++++ b/configure.py +@@ -1282,7 +1282,6 @@ def configure_node(o): + + # Enable branch protection for arm64 + if target_arch == 'arm64': +- o['cflags']+=['-msign-return-address=all'] + o['variables']['arm_fpu'] = options.arm_fpu or 'neon' + + if options.node_snapshot_main is not None: