From 853ea061b842eb8ad1d2a2c3252dca61086a7866 Mon Sep 17 00:00:00 2001 From: Hirokazu MORIKAWA Date: Mon, 10 Mar 2025 09:29:09 +0900 Subject: [PATCH] node: make hostpkg only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/openwrt/packages/issues/26078 As a result of the discussion in this thread, the node.js package was changed to hostpkg only.
In addition, this fix uses the pre-built version distributed on nodejs. The use of pre-build is based on the suggestion of @artynet. The packages in the node module are successfully built, but the target node.js itself cannot be provided, so it cannot be used. Yarn, which is used in packages for web front ends, etc., can be used without any problems. Support for host builds other than linux x86_64. Signed-off-by: Hirokazu MORIKAWA --- lang/node/Makefile | 133 ++++---------- lang/node/patches/003-path.patch | 12 -- lang/node/patches/004-musl_support.patch | 42 ----- lang/node/patches/200-uv_gyp.patch | 10 -- lang/node/patches/201-zlib_gyp.patch | 10 -- lang/node/patches/202-node_gyp.patch | 18 -- lang/node/patches/203-icu-generic_gyp.patch | 106 ----------- lang/node/patches/204-v8_gyp.patch | 166 ------------------ .../patches/999-localhost-no-addrconfig.patch | 29 --- ...able_pointer_authentication_on_arm64.patch | 10 -- 10 files changed, 31 insertions(+), 505 deletions(-) delete mode 100644 lang/node/patches/003-path.patch delete mode 100644 lang/node/patches/004-musl_support.patch delete mode 100644 lang/node/patches/200-uv_gyp.patch delete mode 100644 lang/node/patches/201-zlib_gyp.patch delete mode 100644 lang/node/patches/202-node_gyp.patch delete mode 100644 lang/node/patches/203-icu-generic_gyp.patch delete mode 100644 lang/node/patches/204-v8_gyp.patch delete mode 100644 lang/node/patches/999-localhost-no-addrconfig.patch delete mode 100644 lang/node/patches/999-revert_enable_pointer_authentication_on_arm64.patch diff --git a/lang/node/Makefile b/lang/node/Makefile index 7b841012c9..87e4846eb2 100644 --- a/lang/node/Makefile +++ b/lang/node/Makefile @@ -16,6 +16,7 @@ PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://nodejs.org/dist/v$(PKG_VERSION) PKG_HASH:=6c4e31ed5702dc45cfd8c435af56a36a474427e1bd7afe74c346136060beba8a PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-v$(PKG_VERSION) +NODEJS_BIN_SUM:=9d942932535988091034dc94cc5f42b6dc8784d6366df3a36c4c9ccb3996f0c2 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-v$(PKG_VERSION) PKG_MAINTAINER:=Hirokazu MORIKAWA , Adrian Panella @@ -25,11 +26,7 @@ PKG_CPE_ID:=cpe:/a:nodejs:node.js HOST_BUILD_DEPENDS:=python3/host HOST_BUILD_PARALLEL:=1 - -PKG_BUILD_DEPENDS:=python3/host -PKG_BUILD_PARALLEL:=1 -PKG_INSTALL:=1 -PKG_ASLR_PIE:=0 +PKG_HOST_ONLY:=1 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk @@ -40,125 +37,57 @@ define Package/node SUBMENU:=Node.js TITLE:=Node.js is a platform built on Chrome's JavaScript runtime URL:=https://nodejs.org/ - DEPENDS:=@HAS_FPU @(i386||x86_64||arm||aarch64) @BROKEN \ - +libstdcpp +libopenssl +zlib +libnghttp2 \ - +libcares +libatomic +NODEJS_ICU_SYSTEM:icu +NODEJS_ICU_SYSTEM:icu-full-data ABI_VERSION:=$(NODE_MODULE_VERSION) + BUILDONLY:=1 endef define Package/node/description Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world. - - *** The following preparations must be made on the host side. *** - 1. gcc 10.1 or higher is required. - 2. To build a 32-bit target, gcc-multilib, g++-multilib are required. - 3. Requires libatomic package. (If necessary, install the 32-bit library at the same time.) - ex) sudo apt-get install gcc-multilib g++-multilib endef -define Package/node-npm - SECTION:=lang - CATEGORY:=Languages - SUBMENU:=Node.js - TITLE:=NPM stands for Node Package Manager - URL:=https://www.npmjs.com/ - DEPENDS:=+node -endef - -define Package/node-npm/description - NPM is the package manager for NodeJS -endef - -define Package/node/config - if PACKAGE_node - choice - prompt "i18n features" - default NODEJS_ICU_SMALL - help - Select i18n features - - config NODEJS_ICU_NONE - bool "Disable" - - config NODEJS_ICU_SMALL - bool "small-icu" - - config NODEJS_ICU_SYSTEM - depends on ARCH_64BIT - bool "system-icu" - endchoice - endif -endef - -NODEJS_CPU:=$(subst aarch64,arm64,$(subst x86_64,x64,$(subst i386,ia32,$(ARCH)))) - -ifneq ($(CONFIG_ARCH_64BIT),y) -FORCE_32BIT:=-m32 -endif - -MAKE_VARS+= \ - DESTCPU=$(NODEJS_CPU) \ - NO_LOAD='cctest.target.mk embedtest.target.mk node_mksnapshot.target.mk overlapped-checker.target.mk \ - mkcodecache.target.mk tools/v8_gypfiles/torque_base.target.mk tools/v8_gypfiles/v8_init.target.mk' \ - LD_LIBRARY_PATH=$(STAGING_DIR_HOSTPKG)/share/icu/current/lib - HOST_MAKE_VARS+=NO_LOAD='cctest.target.mk embedtest.target.mk overlapped-checker.target.mk' -CONFIGURE_VARS:= \ - CC="$(TARGET_CC) $(TARGET_OPTIMIZATION)" \ - CXX="$(TARGET_CXX) $(TARGET_OPTIMIZATION)" \ - CC_host="$(HOSTCC) $(FORCE_32BIT)" \ - CXX_host="$(HOSTCXX) $(FORCE_32BIT)" - -CONFIGURE_ARGS:= \ - --dest-cpu=$(NODEJS_CPU) \ - --dest-os=linux \ - --cross-compiling \ - --shared-zlib \ - --shared-openssl \ - --shared-nghttp2 \ - --shared-cares \ - --with-intl=$(if $(CONFIG_NODEJS_ICU_SMALL),small-icu,$(if $(CONFIG_NODEJS_ICU_SYSTEM),system-icu,none)) \ - $(if $(findstring +neon",$(CONFIG_CPU_TYPE)),--with-arm-fpu=neon) \ - $(if $(findstring +neon-vfpv4",$(CONFIG_CPU_TYPE)),--with-arm-fpu=neon) \ - $(if $(findstring +vfpv4",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3) \ - $(if $(findstring +vfp",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfp) \ - $(if $(findstring +vfpv3",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3) \ - $(if $(findstring +vfpv3-d16",$(CONFIG_CPU_TYPE)),--with-arm-fpu=vfpv3-d16) \ - --prefix=/usr - HOST_CONFIGURE_VARS:= - HOST_CONFIGURE_ARGS:= \ --dest-os=$(if $(findstring Darwin,$(HOST_OS)),mac,linux) \ --with-intl=small-icu \ --prefix=$(STAGING_DIR_HOSTPKG) -define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ +ifeq ($(HOST_ARCH),x86_64) + +NODEJS_BIN:=node-v$(PKG_VERSION)-linux-x64.tar.gz + +define Download/nodebin + URL:=https://nodejs.org/download/release/v$(PKG_VERSION)/ + FILE:=$(NODEJS_BIN) + HASH:=$(NODEJS_BIN_SUM) endef -define Package/node/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/node $(1)/usr/bin/ +define Host/Prepare + $(eval $(call Download,nodebin)) endef -define Package/node-npm/install - $(INSTALL_DIR) $(1)/usr/lib/node_modules/npm - $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{package.json,LICENSE} \ - $(1)/usr/lib/node_modules/npm/ - $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/README.md \ - $(1)/usr/lib/node_modules/npm/ - $(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{node_modules,bin,lib} \ - $(1)/usr/lib/node_modules/npm/ - $(INSTALL_DIR) $(1)/usr/bin - $(LN) ../lib/node_modules/npm/bin/npm-cli.js $(1)/usr/bin/npm - $(LN) ../lib/node_modules/npm/bin/npx-cli.js $(1)/usr/bin/npx +define Host/Configure + # nothing to do +endef + +define Host/Compile + # nothing to do endef +define Host/Install + rm -f $(1)/bin/npm + rm -f $(1)/bin/npx + rm -rf $(1)/lib/node_modules/npm + rm -f $(1)/bin/corepack + rm -rf $(1)/lib/node_modules/corepack + $(TAR) xvf $(DL_DIR)/$(NODEJS_BIN) -C $(1) --strip-components=1 + mv $(1)/{CHANGELOG.md,LICENSE,README.md} $(1)/lib/node_modules/ +endef + +else define Host/Install rm -f $(1)/bin/npm rm -f $(1)/bin/npx @@ -167,7 +96,7 @@ define Host/Install rm -rf $(1)/lib/node_modules/corepack $(call Host/Install/Default) endef +endif $(eval $(call HostBuild)) $(eval $(call BuildPackage,node)) -$(eval $(call BuildPackage,node-npm)) diff --git a/lang/node/patches/003-path.patch b/lang/node/patches/003-path.patch deleted file mode 100644 index 143d89989f..0000000000 --- a/lang/node/patches/003-path.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/lib/internal/modules/cjs/loader.js -+++ b/lib/internal/modules/cjs/loader.js -@@ -1811,7 +1811,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/004-musl_support.patch b/lang/node/patches/004-musl_support.patch deleted file mode 100644 index d8a02f33f8..0000000000 --- a/lang/node/patches/004-musl_support.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- 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 -@@ -1207,7 +1207,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/200-uv_gyp.patch b/lang/node/patches/200-uv_gyp.patch deleted file mode 100644 index 9e3961763a..0000000000 --- a/lang/node/patches/200-uv_gyp.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/deps/uv/uv.gyp -+++ b/deps/uv/uv.gyp -@@ -156,6 +156,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 -@@ -1368,13 +1369,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/999-revert_enable_pointer_authentication_on_arm64.patch b/lang/node/patches/999-revert_enable_pointer_authentication_on_arm64.patch deleted file mode 100644 index e281dcb55f..0000000000 --- a/lang/node/patches/999-revert_enable_pointer_authentication_on_arm64.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/node.gyp -+++ b/node.gyp -@@ -1139,6 +1139,7 @@ - 'node.gypi' - ], - 'libraries!':[ '-licui18n', '-licuuc', '-licudata', '-lcrypto', '-lssl', '-lz', '-lhttp_parser', '-luv', '-lnghttp2', '-lcares' ], -+ 'cflags!': ['-mbranch-protection=standard'], - 'include_dirs': [ - 'src', - 'tools/msvs/genfiles',