node: add v20.x LTS support

This commit is contained in:
coolsnowwolf 2024-05-05 15:09:10 +08:00
parent 52f6fcd204
commit 5ca5a77660
12 changed files with 435 additions and 6 deletions

View File

@ -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

View File

@ -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'));

View File

@ -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 <execinfo.h>

View File

@ -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)

View File

@ -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

View File

@ -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!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'include',
'src/',

View File

@ -0,0 +1,10 @@
--- a/deps/zlib/zlib.gyp
+++ b/deps/zlib/zlib.gyp
@@ -9,6 +9,7 @@
'arm_fpu%': '',
'llvm_version%': '0.0',
},
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'conditions': [
['use_system_zlib==0', {
'targets': [

View File

@ -0,0 +1,10 @@
--- a/node.gyp
+++ b/node.gyp
@@ -1197,6 +1197,7 @@
'dependencies': [
'deps/simdutf/simdutf.gyp:simdutf#host',
],
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'include_dirs': [
'tools',
'src',

View File

@ -0,0 +1,106 @@
--- a/tools/icu/icu-generic.gyp
+++ b/tools/icu/icu-generic.gyp
@@ -106,6 +106,7 @@
'sources': [
'<@(icu_src_i18n)'
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/i18n',
],
@@ -114,6 +115,7 @@
],
'dependencies': [ 'icuucx', 'icu_implementation', 'icu_uconfig', 'icu_uconfig_target' ],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/i18n',
],
@@ -200,6 +202,7 @@
# full data - no trim needed
'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
'dependencies': [ 'genccode#host', 'icupkg#host', 'icu_implementation#host', 'icu_uconfig' ],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
],
@@ -284,6 +287,7 @@
# This file contains the small ICU data
'sources': [ '<(SHARED_INTERMEDIATE_DIR)/icusmdt<(icu_ver_major)_dat.<(icu_asm_ext)' ],
# for umachine.h
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
],
@@ -300,6 +304,7 @@
'sources': [
'<@(icu_src_stubdata)'
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
],
@@ -339,6 +344,7 @@
'_XOPEN_SOURCE_EXTENDED=0',
]}],
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
],
@@ -348,6 +354,7 @@
'cflags_c': ['-std=c99'],
'export_dependent_settings': [ 'icu_uconfig', 'icu_uconfig_target' ],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
],
@@ -378,6 +385,7 @@
'<(icu_path)/source/tools/toolutil/dbgutil.cpp',
'<(icu_path)/source/tools/toolutil/dbgutil.h',
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
'<(icu_path)/source/i18n',
@@ -397,6 +405,7 @@
}]
],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(icu_path)/source/common',
'<(icu_path)/source/i18n',
@@ -418,6 +427,7 @@
'target_name': 'genrb',
'type': 'executable',
'toolsets': [ 'host' ],
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'dependencies': [ 'icutools', 'icu_implementation' ],
'sources': [
'<@(icu_src_genrb)'
@@ -440,6 +450,7 @@
'target_name': 'iculslocs',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'dependencies': [ 'icutools' ],
'sources': [
'iculslocs.cc',
@@ -458,6 +469,7 @@
'target_name': 'icupkg',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'dependencies': [ 'icutools' ],
'sources': [
'<@(icu_src_icupkg)',
@@ -475,6 +487,7 @@
'target_name': 'genccode',
'toolsets': [ 'host' ],
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'dependencies': [ 'icutools' ],
'sources': [
'<@(icu_src_genccode)',

View File

@ -0,0 +1,158 @@
--- a/tools/v8_gypfiles/v8.gyp
+++ b/tools/v8_gypfiles/v8.gyp
@@ -73,6 +73,7 @@
],
'hard_dependency': 1,
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
@@ -194,6 +195,7 @@
'<@(torque_outputs_cc)',
'<@(torque_outputs_inc)',
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
@@ -215,6 +217,7 @@
'sources': [
'<(generate_bytecode_builtins_list_output)',
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(generate_bytecode_output_root)',
'<(SHARED_INTERMEDIATE_DIR)',
@@ -252,6 +255,7 @@
'sources': [
'<(V8_ROOT)/src/init/setup-isolate-full.cc',
],
+ 'include_dirs': [ '<!@(echo "$STAGING_DIR"/usr/../usr/include)' ],
}, # v8_init
{
'target_name': 'v8_initializers',
@@ -263,9 +267,11 @@
'v8_shared_internal_headers',
'v8_pch',
],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
'<(generate_bytecode_output_root)',
+ '<!@(echo "$STAGING_DIR"/usr/../usr/include)',
],
'sources': [
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?sources = ")',
@@ -694,6 +700,7 @@
'toolsets': ['host', 'target'],
'direct_dependent_settings': {
'sources': ['<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "v8_compiler_sources = ")'],
+ 'include_dirs': [ '<!@(echo "$STAGING_DIR"/usr/../usr/include)' ],
'conditions': [
['v8_target_arch=="ia32"', {
'sources': [
@@ -802,6 +809,8 @@
'target_name': 'v8_turboshaft',
'type': 'static_library',
'toolsets': ['host', 'target'],
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
+ 'include_dirs': [ '<!@(echo "$STAGING_DIR"/usr/../usr/include)' ],
'dependencies': [
'generate_bytecode_builtins_list',
'run_torque',
@@ -826,6 +835,7 @@
'run_torque',
'v8_maybe_icu',
],
+ 'include_dirs': [ '<!@(echo "$STAGING_DIR"/usr/../usr/include)' ],
'conditions': [
['(is_component_build and not v8_optimized_debug and v8_enable_fast_mksnapshot) or v8_enable_turbofan==0', {
'dependencies': [
@@ -866,6 +876,7 @@
],
'includes': ['inspector.gypi'],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(generate_bytecode_output_root)',
'<(SHARED_INTERMEDIATE_DIR)',
@@ -1495,6 +1506,7 @@
}],
],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(V8_ROOT)/include',
],
@@ -1515,6 +1527,7 @@
{
'target_name': 'bytecode_builtins_list_generator',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'conditions': [
['want_separate_host_toolset', {
'toolsets': ['host'],
@@ -1543,6 +1556,9 @@
{
'target_name': 'mksnapshot',
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
+ 'library_dirs':[ '../../../../staging_dir/hostpkg/share/icu/current/lib' ],
+ 'include_dirs': [ '<!@(echo "$STAGING_DIR"/usr/../usr/include)' ],
'dependencies': [
'v8_base_without_compiler',
'v8_compiler_for_mksnapshot',
@@ -1570,6 +1586,7 @@
{
'target_name': 'torque',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'dependencies': [
'torque_base',
# "build/win:default_exe_manifest",
@@ -1612,6 +1629,7 @@
{
'target_name': 'torque-language-server',
'type': 'executable',
+ 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
'conditions': [
['want_separate_host_toolset', {
'toolsets': ['host'],
@@ -1643,6 +1661,8 @@
{
'target_name': 'gen-regexp-special-case',
'type': 'executable',
+ 'libraries!':[ '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ],
+ 'library_dirs':[ '../../../../staging_dir/hostpkg/share/icu/current/lib' ],
'dependencies': [
'v8_libbase',
# "build/win:default_exe_manifest",
@@ -1861,6 +1881,7 @@
}],
],
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(V8_ROOT)/include',
],
@@ -1988,15 +2009,19 @@
'WARNING_CFLAGS!': ['-Wno-invalid-offsetof']
},
'direct_dependent_settings': {
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
+ '<!@(echo "$STAGING_DIR"/usr/../usr/include)',
],
},
'defines': [ 'ZLIB_IMPLEMENTATION' ],
+ 'include_dirs!': [ '<!@(echo "$STAGING_DIR"/usr/include)' ],
'include_dirs': [
'<(V8_ROOT)/third_party/zlib',
'<(V8_ROOT)/third_party/zlib/google',
+ '<!@(echo "$STAGING_DIR"/usr/../usr/include)',
],
'sources': [
'<(V8_ROOT)/third_party/zlib/adler32.c',

View File

@ -0,0 +1,29 @@
Description: do not use dns.ADDRCONFIG for localhost
it fails on IPv6-only systems. Setting it with libc fails on linux.
https://github.com/nodejs/node/issues/33279
Author: Jérémy Lal <kapouer@melix.org>
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;

View File

@ -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: