From dddd5b0a9b9598764084c4b27a1b76619164cc45 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Fri, 10 Sep 2021 11:08:48 +0530 Subject: [PATCH 01/14] nodejs: Hardcode linker flags for shared libraries We are passing flags to `configure.py` in order to tell the nodejs build toolchain to use shared libraries. The toolchain seems to mistakenly also try use shared libraries for host build, but it does not add respective linker flags (For example `-lz` for zlib). This commit hardcodes these flags to be always passed to linker by setting linker to linker + LDFLAGS of shared libraries --- packages/nodejs/Makefile.patch | 10 +++ packages/nodejs/avoid-ficlone-ioctl.patch | 16 ++-- packages/nodejs/build.sh | 9 ++- packages/nodejs/deps-uv-src-unix-core.c.patch | 10 +-- .../nodejs/deps-uv-src-unix-process.c.patch | 7 +- packages/nodejs/deps-uv-uv.gyp.patch | 9 +-- packages/nodejs/deps-v8-BUILD.gn.patch | 11 +++ ...deps-v8-src-flags-flag-definitions.h.patch | 7 +- .../nodejs/deps-v8-src-logging-log.cc.patch | 7 +- .../nodejs/fix_multiple_definitions.patch | 12 +-- packages/nodejs/lib-child_process.js.patch | 7 +- packages/nodejs/lib-os.js.patch | 11 ++- packages/nodejs/no-android-log.patch | 29 +------ packages/nodejs/node.gyp.patch | 25 ++++--- packages/nodejs/npm-link-patch.patch | 29 ------- packages/nodejs/src-cares_wrap.cc.patch | 12 --- packages/nodejs/src-cares_wrap.h.patch | 12 +++ packages/nodejs/src-node_internals.h.patch | 7 +- packages/nodejs/src-node_main.cc.patch | 9 +-- .../nodejs/tools-v8_gypfiles-v8.gyp.patch | 13 ++-- ...all-new-ListFormatter-createInstance.patch | 75 ------------------- 21 files changed, 109 insertions(+), 218 deletions(-) create mode 100644 packages/nodejs/Makefile.patch create mode 100644 packages/nodejs/deps-v8-BUILD.gn.patch delete mode 100644 packages/nodejs/npm-link-patch.patch delete mode 100644 packages/nodejs/src-cares_wrap.cc.patch create mode 100644 packages/nodejs/src-cares_wrap.h.patch delete mode 100644 packages/nodejs/v8-call-new-ListFormatter-createInstance.patch diff --git a/packages/nodejs/Makefile.patch b/packages/nodejs/Makefile.patch new file mode 100644 index 000000000..1690efcb6 --- /dev/null +++ b/packages/nodejs/Makefile.patch @@ -0,0 +1,10 @@ +--- ./Makefile 2021-09-10 11:00:12.544728388 +0530 ++++ ./Makefile.mod 2021-09-10 11:04:27.388422344 +0530 +@@ -19,6 +19,7 @@ + PWD = $(CURDIR) + BUILD_WITH ?= make + FIND ?= find ++V8_ARCH = $(DESTCPU) + + ifdef JOBS + PARALLEL_ARGS = -j $(JOBS) diff --git a/packages/nodejs/avoid-ficlone-ioctl.patch b/packages/nodejs/avoid-ficlone-ioctl.patch index bbb6e309f..15e4d610e 100644 --- a/packages/nodejs/avoid-ficlone-ioctl.patch +++ b/packages/nodejs/avoid-ficlone-ioctl.patch @@ -1,20 +1,20 @@ -diff -uNr node-v13.0.0/deps/uv/src/unix/fs.c node-v13.0.0.mod/deps/uv/src/unix/fs.c ---- node-v13.0.0/deps/uv/src/unix/fs.c 2019-10-22 17:23:28.000000000 +0300 -+++ node-v13.0.0.mod/deps/uv/src/unix/fs.c 2020-01-16 02:27:44.944603915 +0200 -@@ -1048,6 +1048,7 @@ - goto out; + +diff -uNr ./deps/uv/src/unix/fs.c ./deps/uv/src/unix/fs.c.mod +--- ./deps/uv/src/unix/fs.c 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/uv/src/unix/fs.c.mod 2021-06-18 20:05:49.675642773 +0530 +@@ -1247,6 +1247,7 @@ + #endif /* !__linux__ */ } +#ifndef __ANDROID__ #ifdef FICLONE if (req->flags & UV_FS_COPYFILE_FICLONE || req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { -@@ -1072,7 +1073,7 @@ +@@ -1267,6 +1268,7 @@ goto out; } #endif -- +#endif + bytes_to_send = src_statsbuf.st_size; in_offset = 0; - while (bytes_to_send != 0) { diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index b2881ac6f..72bfab30a 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -4,10 +4,9 @@ TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@termux" # Note: package build may fail on Github Actions CI due to out-of-memory # condition. It should be built locally instead. -TERMUX_PKG_VERSION=14.15.4 -TERMUX_PKG_REVISION=2 +TERMUX_PKG_VERSION=16.6.1 TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=adb7ecf66c74b52a14a08cc22bb0f9aedc157cac1ac93240f7f455e8c8edec9c +TERMUX_PKG_SHA256=79b1ea058cc67f2a69462cd5f2467a1efe08c64299c053da70384ce1a0e3e557 # Note that we do not use a shared libuv to avoid an issue with the Android # linker, which does not use symbols of linked shared libraries when resolving # symbols on dlopen(). See https://github.com/termux/termux-packages/issues/462. @@ -77,7 +76,9 @@ termux_step_configure() { export GYP_DEFINES="host_os=linux" export CC_host=gcc export CXX_host=g++ - export LINK_host=g++ + export LINK_host="g++ -Wl,--no-as-needed -ldl -lz" + + LDFLAGS+=" -Wl,--no-as-needed -ldl" # See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv. ./configure \ diff --git a/packages/nodejs/deps-uv-src-unix-core.c.patch b/packages/nodejs/deps-uv-src-unix-core.c.patch index 64f8107cb..8876339b0 100644 --- a/packages/nodejs/deps-uv-src-unix-core.c.patch +++ b/packages/nodejs/deps-uv-src-unix-core.c.patch @@ -1,13 +1,11 @@ -diff -uNr node-v8.4.0/deps/uv/src/unix/core.c node-v8.4.0.mod/deps/uv/src/unix/core.c ---- node-v8.4.0/deps/uv/src/unix/core.c 2017-08-15 19:42:28.000000000 +0300 -+++ node-v8.4.0.mod/deps/uv/src/unix/core.c 2017-09-14 16:13:27.292856099 +0300 -@@ -1112,7 +1112,9 @@ +diff -uNr ./deps/uv/src/unix/core.c ./deps/uv/src/unix/core.c.mod +--- ./deps/uv/src/unix/core.c 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/uv/src/unix/core.c.mod 2021-06-18 20:10:13.705642672 +0530 +@@ -1116,7 +1116,7 @@ /* No temp environment variables defined */ #if defined(__ANDROID__) - buf = "/data/local/tmp"; -+ // Don't use '/data/local/tmp' in Termux -+ //buf = "/data/local/tmp"; + buf = "@TERMUX_PREFIX@/tmp"; #else buf = "/tmp"; diff --git a/packages/nodejs/deps-uv-src-unix-process.c.patch b/packages/nodejs/deps-uv-src-unix-process.c.patch index bed8b0b2c..7cdd7774c 100644 --- a/packages/nodejs/deps-uv-src-unix-process.c.patch +++ b/packages/nodejs/deps-uv-src-unix-process.c.patch @@ -1,7 +1,6 @@ -diff -uNr node-v12.10.0/deps/uv/src/unix/process.c node-v12.10.0.mod/deps/uv/src/unix/process.c ---- node-v12.10.0/deps/uv/src/unix/process.c 2019-09-04 18:36:23.000000000 +0300 -+++ node-v12.10.0.mod/deps/uv/src/unix/process.c 2019-09-23 01:39:39.069030779 +0300 -@@ -351,27 +351,6 @@ +--- ./deps/uv/src/unix/process.c 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/uv/src/unix/process.c.mod 2021-06-18 20:15:54.095642543 +0530 +@@ -281,27 +281,6 @@ _exit(127); } diff --git a/packages/nodejs/deps-uv-uv.gyp.patch b/packages/nodejs/deps-uv-uv.gyp.patch index c19f5c1c2..756af45de 100644 --- a/packages/nodejs/deps-uv-uv.gyp.patch +++ b/packages/nodejs/deps-uv-uv.gyp.patch @@ -1,7 +1,6 @@ -diff -u -r ../node-v9.7.1/deps/uv/uv.gyp ./deps/uv/uv.gyp ---- ../node-v9.7.1/deps/uv/uv.gyp 2018-03-02 01:58:02.000000000 +0000 -+++ ./deps/uv/uv.gyp 2018-03-05 10:51:15.530165566 +0000 -@@ -39,7 +39,7 @@ +--- ./deps/uv/uv.gyp 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/uv/uv.gyp.mod 2021-06-18 20:21:23.955642417 +0530 +@@ -40,7 +40,7 @@ { 'target_name': 'libuv', 'type': '<(uv_library)', @@ -10,7 +9,7 @@ diff -u -r ../node-v9.7.1/deps/uv/uv.gyp ./deps/uv/uv.gyp 'include', 'src/', ], -@@ -54,7 +54,7 @@ +@@ -55,7 +55,7 @@ '<@(shared_unix_defines)', '<@(shared_zos_defines)', ], diff --git a/packages/nodejs/deps-v8-BUILD.gn.patch b/packages/nodejs/deps-v8-BUILD.gn.patch new file mode 100644 index 000000000..66ac0f097 --- /dev/null +++ b/packages/nodejs/deps-v8-BUILD.gn.patch @@ -0,0 +1,11 @@ +--- ./deps/v8/BUILD.gn 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/v8/BUILD.gn.mod 2021-07-17 17:32:54.134091233 +0530 +@@ -17,6 +17,8 @@ + import("gni/snapshot_toolchain.gni") + import("gni/v8.gni") + ++v8_target_cpu = getenv("DEST_CPU") ++ + # Specifies if the target build is a simulator build. Comparing target cpu + # with v8 target cpu to not affect simulator builds for making cross-compile + # snapshots. diff --git a/packages/nodejs/deps-v8-src-flags-flag-definitions.h.patch b/packages/nodejs/deps-v8-src-flags-flag-definitions.h.patch index 247c8ad84..0118c3f84 100644 --- a/packages/nodejs/deps-v8-src-flags-flag-definitions.h.patch +++ b/packages/nodejs/deps-v8-src-flags-flag-definitions.h.patch @@ -1,7 +1,6 @@ -diff -u -r ../node-v14.0.0/deps/v8/src/flags/flag-definitions.h ./deps/v8/src/flags/flag-definitions.h ---- ../node-v14.0.0/deps/v8/src/flags/flag-definitions.h 2020-04-21 11:38:50.000000000 +0000 -+++ ./deps/v8/src/flags/flag-definitions.h 2020-04-28 23:22:24.894254000 +0000 -@@ -1555,7 +1555,7 @@ +--- ./deps/v8/src/flags/flag-definitions.h 2021-06-03 07:15:31.000000000 +0530 ++++ ./deps/v8/src/flags/flag-definitions.h.mod 2021-06-18 20:24:38.915642342 +0530 +@@ -1842,7 +1842,7 @@ #undef DEFINE_PERF_PROF_BOOL #undef DEFINE_PERF_PROF_IMPLICATION diff --git a/packages/nodejs/deps-v8-src-logging-log.cc.patch b/packages/nodejs/deps-v8-src-logging-log.cc.patch index b3e6a8bc0..bd0b9b599 100644 --- a/packages/nodejs/deps-v8-src-logging-log.cc.patch +++ b/packages/nodejs/deps-v8-src-logging-log.cc.patch @@ -1,7 +1,6 @@ -diff -u -r ../node-v12.9.0/deps/v8/src/logging/log.cc ./deps/v8/src/logging/log.cc ---- ../node-v12.9.0/deps/v8/src/logging/log.cc 2019-08-20 17:14:50.000000000 +0000 -+++ ./deps/v8/src/logging/log.cc 2019-08-24 22:39:52.426124955 +0000 -@@ -280,7 +280,7 @@ +--- ./deps/v8/src/logging/log.cc 2021-06-03 07:15:31.000000000 +0530 ++++ ./deps/v8/src/logging/log.cc.mod 2021-06-18 20:27:34.605642275 +0530 +@@ -291,7 +291,7 @@ FILE* perf_output_handle_; }; diff --git a/packages/nodejs/fix_multiple_definitions.patch b/packages/nodejs/fix_multiple_definitions.patch index d21cba739..a0ab7b631 100644 --- a/packages/nodejs/fix_multiple_definitions.patch +++ b/packages/nodejs/fix_multiple_definitions.patch @@ -1,6 +1,5 @@ -diff -uNr node-v12.3.1/deps/uv/src/unix/sysinfo-memory.c node-v12.3.1.mod/deps/uv/src/unix/sysinfo-memory.c ---- node-v12.3.1/deps/uv/src/unix/sysinfo-memory.c 2019-05-22 15:21:52.000000000 +0300 -+++ node-v12.3.1.mod/deps/uv/src/unix/sysinfo-memory.c 2019-05-28 15:37:28.698418026 +0300 +--- ./deps/uv/src/unix/sysinfo-memory.c 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/uv/src/unix/sysinfo-memory.c.mod 2021-06-18 20:31:00.255642197 +0530 @@ -25,6 +25,7 @@ #include #include @@ -9,8 +8,11 @@ diff -uNr node-v12.3.1/deps/uv/src/unix/sysinfo-memory.c node-v12.3.1.mod/deps/u uint64_t uv_get_free_memory(void) { struct sysinfo info; -@@ -40,3 +41,4 @@ - return (uint64_t) info.totalram * info.mem_unit; +@@ -32,6 +33,7 @@ + return (uint64_t) info.freeram * info.mem_unit; return 0; } +#endif + + uint64_t uv_get_total_memory(void) { + struct sysinfo info; diff --git a/packages/nodejs/lib-child_process.js.patch b/packages/nodejs/lib-child_process.js.patch index 740e40cf7..176285b3f 100644 --- a/packages/nodejs/lib-child_process.js.patch +++ b/packages/nodejs/lib-child_process.js.patch @@ -1,7 +1,6 @@ -diff -u -r ../node-v6.2.0/lib/child_process.js ./lib/child_process.js ---- ../node-v6.2.0/lib/child_process.js 2016-05-17 15:53:06.000000000 -0400 -+++ ./lib/child_process.js 2016-05-18 16:31:45.574685443 -0400 -@@ -335,7 +335,7 @@ +--- ./lib/child_process.js 2021-06-03 07:15:32.000000000 +0530 ++++ ./lib/child_process.js.mod 2021-06-18 20:32:47.215642156 +0530 +@@ -520,7 +520,7 @@ if (typeof options.shell === 'string') file = options.shell; else if (process.platform === 'android') diff --git a/packages/nodejs/lib-os.js.patch b/packages/nodejs/lib-os.js.patch index 02d345fa5..2a50bf32a 100644 --- a/packages/nodejs/lib-os.js.patch +++ b/packages/nodejs/lib-os.js.patch @@ -1,12 +1,11 @@ -diff -u -r ../node-v10.9.0/lib/os.js ./lib/os.js ---- ../node-v10.9.0/lib/os.js 2018-08-15 13:53:34.000000000 +0000 -+++ ./lib/os.js 2018-08-23 20:42:39.611186774 +0000 -@@ -130,7 +130,7 @@ +--- ./lib/os.js 2021-06-03 07:15:32.000000000 +0530 ++++ ./lib/os.js.mod 2021-06-18 20:34:28.215642118 +0530 +@@ -183,7 +183,7 @@ path = safeGetenv('TMPDIR') || safeGetenv('TMP') || safeGetenv('TEMP') || - '/tmp'; + '@TERMUX_PREFIX@/tmp'; - if (path.length > 1 && path.endsWith('/')) - path = path.slice(0, -1); + if (path.length > 1 && StringPrototypeEndsWith(path, '/')) + path = StringPrototypeSlice(path, 0, -1); } diff --git a/packages/nodejs/no-android-log.patch b/packages/nodejs/no-android-log.patch index 513dc77b4..bb13d0d17 100644 --- a/packages/nodejs/no-android-log.patch +++ b/packages/nodejs/no-android-log.patch @@ -1,6 +1,5 @@ -diff -uNr node-v14.0.0/deps/v8/BUILD.gn node-v14.0.0.mod/deps/v8/BUILD.gn ---- node-v14.0.0/deps/v8/BUILD.gn 2020-04-21 11:38:50.000000000 +0000 -+++ node-v14.0.0.mod/deps/v8/BUILD.gn 2020-05-07 14:11:12.247429516 +0000 +--- ./deps/v8/BUILD.gn 2021-06-03 07:15:30.000000000 +0530 ++++ ./deps/v8/BUILD.gn.mod 2021-06-18 20:42:14.845641940 +0530 @@ -28,7 +28,7 @@ declare_args() { @@ -10,27 +9,3 @@ diff -uNr node-v14.0.0/deps/v8/BUILD.gn node-v14.0.0.mod/deps/v8/BUILD.gn # Dynamically set an additional dependency from v8/custom_deps. v8_custom_deps = "" -diff -uNr node-v14.0.0/deps/v8/infra/mb/mb_config.pyl node-v14.0.0.mod/deps/v8/infra/mb/mb_config.pyl ---- node-v14.0.0/deps/v8/infra/mb/mb_config.pyl 2020-04-21 11:38:50.000000000 +0000 -+++ node-v14.0.0.mod/deps/v8/infra/mb/mb_config.pyl 2020-05-07 14:12:44.653746359 +0000 -@@ -565,7 +565,7 @@ - - 'mixins': { - 'android': { -- 'gn_args': 'target_os="android" v8_android_log_stdout=true', -+ 'gn_args': 'target_os="android" v8_android_log_stdout=false', - }, - - 'android_strip_outputs': { -diff -uNr node-v14.0.0/src/debug_utils.cc node-v14.0.0.mod/src/debug_utils.cc ---- node-v14.0.0/src/debug_utils.cc 2020-04-21 11:38:51.000000000 +0000 -+++ node-v14.0.0.mod/src/debug_utils.cc 2020-05-07 14:12:00.694741330 +0000 -@@ -500,7 +500,7 @@ - - WriteConsoleW(handle, wbuf.data(), n, nullptr, nullptr); - return; --#elif defined(__ANDROID__) -+#elif defined(__ANDROID__) && !defined(__TERMUX__) - if (file == stderr) { - __android_log_print(ANDROID_LOG_ERROR, "nodejs", "%s", str.data()); - return; diff --git a/packages/nodejs/node.gyp.patch b/packages/nodejs/node.gyp.patch index f23796927..c7b3e8770 100644 --- a/packages/nodejs/node.gyp.patch +++ b/packages/nodejs/node.gyp.patch @@ -1,15 +1,17 @@ ---- ./node.gyp.orig 2020-10-17 18:07:04.114992036 +0000 -+++ ./node.gyp 2020-10-17 18:30:04.575629963 +0000 -@@ -1201,101 +1201,6 @@ - }], +diff -uNr node-v16.6.1/node.gyp node-v16.6.1.mod/node.gyp +--- node-v16.6.1/node.gyp 2021-08-03 05:54:26.000000000 +0000 ++++ node-v16.6.1.mod/node.gyp 2021-08-07 05:43:34.342341704 +0000 +@@ -1062,107 +1062,6 @@ ], }, # fuzz_env -- { + { - 'target_name': 'cctest', - 'type': 'executable', - - 'dependencies': [ - '<(node_lib_target_name)', +- 'deps/googletest/googletest.gyp:gtest', +- 'deps/googletest/googletest.gyp:gtest_main', - 'deps/histogram/histogram.gyp:histogram', - 'deps/uvwasi/uvwasi.gyp:uvwasi', - 'node_dtrace_header', @@ -40,8 +42,6 @@ - 'sources': [ - 'src/node_snapshot_stub.cc', - 'src/node_code_cache_stub.cc', -- 'test/cctest/gtest/gtest-all.cc', -- 'test/cctest/gtest/gtest_main.cc', - 'test/cctest/node_test_fixture.cc', - 'test/cctest/node_test_fixture.h', - 'test/cctest/test_aliased_buffer.cc', @@ -49,7 +49,9 @@ - 'test/cctest/test_base_object_ptr.cc', - 'test/cctest/test_node_postmortem_metadata.cc', - 'test/cctest/test_environment.cc', +- 'test/cctest/test_js_native_api_v8.cc', - 'test/cctest/test_linked_binding.cc', +- 'test/cctest/test_node_api.cc', - 'test/cctest/test_per_process.cc', - 'test/cctest/test_platform.cc', - 'test/cctest/test_json_utils.cc', @@ -64,6 +66,9 @@ - 'defines': [ - 'HAVE_OPENSSL=1', - ], +- 'sources': [ +- 'test/cctest/test_node_crypto.cc', +- ] - }], - ['v8_enable_inspector==1', { - 'sources': [ @@ -99,6 +104,8 @@ - }], - ], - }, # cctest - - { +- +- { 'target_name': 'embedtest', + 'type': 'executable', + diff --git a/packages/nodejs/npm-link-patch.patch b/packages/nodejs/npm-link-patch.patch deleted file mode 100644 index 36cdf23ec..000000000 --- a/packages/nodejs/npm-link-patch.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- ../node/deps/npm/node_modules/cacache/lib/util/move-file.js 2017-10-22 19:30:25.778456404 +0200 -+++ ./deps/npm/node_modules/cacache/lib/util/move-file.js 2017-10-22 20:41:18.021337095 +0200 -@@ -4,6 +4,7 @@ - const BB = require('bluebird') - const chmod = BB.promisify(fs.chmod) - const unlink = BB.promisify(fs.unlink) -+const access = BB.promisify(fs.access) - let move - let pinflight - -@@ -18,6 +19,18 @@ - // content their own way. - // - // Note that, as the name suggests, this strictly only supports file moves. -+ -+ -+ // Calling link() on android is not allowed, we get a SELinux security exception -+ if(process.platform === 'android') { -+ return access(dest, fs.constants.F_OK) -+ .catch(err => { -+ if (!move) { move = require('move-concurrently') } -+ return move(src, dest, { BB, fs }) -+ .then(() => chmod(dest, '0444')) -+ }) -+ } -+ - return BB.fromNode(cb => { - fs.link(src, dest, err => { - if (err) { diff --git a/packages/nodejs/src-cares_wrap.cc.patch b/packages/nodejs/src-cares_wrap.cc.patch deleted file mode 100644 index 2d0ca4913..000000000 --- a/packages/nodejs/src-cares_wrap.cc.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -u -r ../node-v6.0.0/src/cares_wrap.cc ./src/cares_wrap.cc ---- ../node-v6.0.0/src/cares_wrap.cc 2016-04-26 15:50:22.000000000 -0400 -+++ ./src/cares_wrap.cc 2016-05-02 00:24:26.349502775 -0400 -@@ -15,8 +15,7 @@ - #include - #include - --#if defined(__ANDROID__) || \ -- defined(__MINGW32__) || \ -+#if defined(__MINGW32__) || \ - defined(__OpenBSD__) || \ - defined(_MSC_VER) diff --git a/packages/nodejs/src-cares_wrap.h.patch b/packages/nodejs/src-cares_wrap.h.patch new file mode 100644 index 000000000..76baf287c --- /dev/null +++ b/packages/nodejs/src-cares_wrap.h.patch @@ -0,0 +1,12 @@ +--- ./src/cares_wrap.h 2021-06-03 07:15:32.000000000 +0530 ++++ ./src/cares_wrap.h.mod 2021-06-19 08:34:10.153760365 +0530 +@@ -22,8 +22,7 @@ + # include + #endif // __POSIX__ + +-#if defined(__ANDROID__) || \ +- defined(__MINGW32__) || \ ++#if defined(__MINGW32__) || \ + defined(__OpenBSD__) || \ + defined(_MSC_VER) + diff --git a/packages/nodejs/src-node_internals.h.patch b/packages/nodejs/src-node_internals.h.patch index 1fa427cb8..43007ce5e 100644 --- a/packages/nodejs/src-node_internals.h.patch +++ b/packages/nodejs/src-node_internals.h.patch @@ -1,7 +1,6 @@ -diff -u -r ../node-v11.7.0/src/node_internals.h ./src/node_internals.h ---- ../node-v11.7.0/src/node_internals.h 2019-01-17 21:27:16.000000000 +0000 -+++ ./src/node_internals.h 2019-01-18 22:44:06.207542176 +0000 -@@ -358,7 +358,7 @@ +--- ./src/node_internals.h 2021-06-03 07:15:32.000000000 +0530 ++++ ./src/node_internals.h.mod 2021-06-18 20:49:41.375641769 +0530 +@@ -286,7 +286,7 @@ // Functions defined in node.cc that are exposed via the bootstrapper object diff --git a/packages/nodejs/src-node_main.cc.patch b/packages/nodejs/src-node_main.cc.patch index 06610ac6b..38ed87d43 100644 --- a/packages/nodejs/src-node_main.cc.patch +++ b/packages/nodejs/src-node_main.cc.patch @@ -1,11 +1,10 @@ -diff -u -r ../node-v6.3.1/src/node_main.cc ./src/node_main.cc ---- ../node-v6.3.1/src/node_main.cc 2016-07-21 16:44:43.000000000 -0400 -+++ ./src/node_main.cc 2016-07-23 13:53:57.530095071 -0400 -@@ -54,6 +54,10 @@ +--- ./src/node_main.cc 2021-06-03 07:15:32.000000000 +0530 ++++ ./src/node_main.cc.mod 2021-06-18 21:13:57.512327727 +0530 +@@ -124,6 +124,10 @@ // calls elsewhere in the program (e.g., any logging from V8.) setvbuf(stdout, nullptr, _IONBF, 0); setvbuf(stderr, nullptr, _IONBF, 0); -+ if (getenv("TMPDIR") == NULL) { ++ if(getenv("TMPDIR") == NULL) { + // Give javascript programs (such as updated versions of npm) a working tmpdir. + putenv("TMPDIR=@TERMUX_PREFIX@/tmp"); + } diff --git a/packages/nodejs/tools-v8_gypfiles-v8.gyp.patch b/packages/nodejs/tools-v8_gypfiles-v8.gyp.patch index 5f547be57..b1aa8aacc 100644 --- a/packages/nodejs/tools-v8_gypfiles-v8.gyp.patch +++ b/packages/nodejs/tools-v8_gypfiles-v8.gyp.patch @@ -1,11 +1,10 @@ -diff -u -r ../node-v12.9.0/tools/v8_gypfiles/v8.gyp ./tools/v8_gypfiles/v8.gyp ---- ../node-v12.9.0/tools/v8_gypfiles/v8.gyp 2019-08-20 17:14:53.000000000 +0000 -+++ ./tools/v8_gypfiles/v8.gyp 2019-08-24 22:02:57.943558855 +0000 -@@ -1010,6 +1010,7 @@ +--- ./tools/v8_gypfiles/v8.gyp 2021-06-03 07:15:33.000000000 +0530 ++++ ./tools/v8_gypfiles/v8.gyp.mod 2021-06-18 21:18:09.722327631 +0530 +@@ -928,6 +928,7 @@ '<(V8_ROOT)/src/base/platform/platform-posix.h', '<(V8_ROOT)/src/base/platform/platform-posix-time.cc', '<(V8_ROOT)/src/base/platform/platform-posix-time.h', -+ '<(V8_ROOT)/src/base/platform/platform-linux.cc', ++ '<(V8_ROOT)/src/base/platform/platform-linux.h', ], - 'conditions': [ - ['_toolset=="host"', { + 'link_settings': { + 'target_conditions': [ diff --git a/packages/nodejs/v8-call-new-ListFormatter-createInstance.patch b/packages/nodejs/v8-call-new-ListFormatter-createInstance.patch deleted file mode 100644 index c710cc4a3..000000000 --- a/packages/nodejs/v8-call-new-ListFormatter-createInstance.patch +++ /dev/null @@ -1,75 +0,0 @@ -diff -uNr ./deps/v8/src/objects/js-list-format.cc ./deps/v8/src/objects/js-list-format.cc.mod ---- ./deps/v8/src/objects/js-list-format.cc 2021-06-16 14:17:02.740441957 +0530 -+++ ./deps/v8/src/objects/js-list-format.cc.mod 2021-06-16 14:14:03.766819789 +0530 -@@ -29,46 +29,27 @@ - namespace internal { - - namespace { --const char* kStandard = "standard"; --const char* kOr = "or"; --const char* kUnit = "unit"; --const char* kStandardShort = "standard-short"; --const char* kOrShort = "or-short"; --const char* kUnitShort = "unit-short"; --const char* kStandardNarrow = "standard-narrow"; --const char* kOrNarrow = "or-narrow"; --const char* kUnitNarrow = "unit-narrow"; - --const char* GetIcuStyleString(JSListFormat::Style style, -- JSListFormat::Type type) { -+UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { -+ switch (style) { -+ case JSListFormat::Style::LONG: -+ return ULISTFMT_WIDTH_WIDE; -+ case JSListFormat::Style::SHORT: -+ return ULISTFMT_WIDTH_SHORT; -+ case JSListFormat::Style::NARROW: -+ return ULISTFMT_WIDTH_NARROW; -+ } -+ UNREACHABLE(); -+} -+ -+UListFormatterType GetIcuType(JSListFormat::Type type) { - switch (type) { - case JSListFormat::Type::CONJUNCTION: -- switch (style) { -- case JSListFormat::Style::LONG: -- return kStandard; -- case JSListFormat::Style::SHORT: -- return kStandardShort; -- case JSListFormat::Style::NARROW: -- return kStandardNarrow; -- } -+ return ULISTFMT_TYPE_AND; - case JSListFormat::Type::DISJUNCTION: -- switch (style) { -- case JSListFormat::Style::LONG: -- return kOr; -- case JSListFormat::Style::SHORT: -- return kOrShort; -- case JSListFormat::Style::NARROW: -- return kOrNarrow; -- } -+ return ULISTFMT_TYPE_OR; - case JSListFormat::Type::UNIT: -- switch (style) { -- case JSListFormat::Style::LONG: -- return kUnit; -- case JSListFormat::Style::SHORT: -- return kUnitShort; -- case JSListFormat::Style::NARROW: -- return kUnitNarrow; -- } -+ return ULISTFMT_TYPE_UNITS; - } - UNREACHABLE(); - } -@@ -143,7 +124,7 @@ - icu::Locale icu_locale = r.icu_locale; - UErrorCode status = U_ZERO_ERROR; - icu::ListFormatter* formatter = icu::ListFormatter::createInstance( -- icu_locale, GetIcuStyleString(style_enum, type_enum), status); -+ icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status); - if (U_FAILURE(status) || formatter == nullptr) { - delete formatter; - THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), From 8979636e7eb96b34b20e824b92161a615e079bae Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sat, 11 Sep 2021 07:54:01 +0530 Subject: [PATCH 02/14] nodejs: Remove x86_64 as blacklisted arch --- packages/nodejs/build.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index 72bfab30a..bb00e79c3 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -18,18 +18,6 @@ TERMUX_PKG_SUGGESTS="clang, make, pkg-config, python" TERMUX_PKG_RM_AFTER_INSTALL="lib/node_modules/npm/html lib/node_modules/npm/make.bat share/systemtap lib/dtrace" TERMUX_PKG_BUILD_IN_SRC=true TERMUX_PKG_HOSTBUILD=true -# Build fails on x86_64 with: -# g++ -rdynamic -m64 -pthread -m64 -fPIC -o /home/builder/.termux-build/nodejs/src/out/Release/mksnapshot ... -# /usr/bin/ld: /home/builder/.termux-build/nodejs/src/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/api/api.o: -# in function `v8::TryHandleWebAssemblyTrapPosix(int, siginfo_t*, void*)': -# api.cc:(.text._ZN2v829TryHandleWebAssemblyTrapPosixEiP9siginfo_tPv+0x5): -# undefined reference to `v8::internal::trap_handler::TryHandleSignal(int, siginfo_t*, void*)' -# /usr/bin/ld: /home/builder/.termux-build/nodejs/src/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/trap-handler/handler-outside.o: -# in function `v8::internal::trap_handler::EnableTrapHandler(bool)': -# handler-outside.cc:(.text._ZN2v88internal12trap_handler17EnableTrapHandlerEb+0x25): -# undefined reference to `v8::internal::trap_handler::RegisterDefaultTrapHandler()' -# collect2: error: ld returned 1 exit status -TERMUX_PKG_BLACKLISTED_ARCHES="x86_64" termux_step_post_get_source() { # Prevent caching of host build: From d6dcb8dc77f9d7a8651310bf9b8b435ccccb037a Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sat, 11 Sep 2021 11:00:44 +0530 Subject: [PATCH 03/14] nodejs: Bump to 16.9.1 --- packages/nodejs/build.sh | 4 ++-- .../nodejs/deps-uv-src-unix-process.c.patch | 22 ++++++++----------- packages/nodejs/src-cares_wrap.h.patch | 12 ---------- 3 files changed, 11 insertions(+), 27 deletions(-) delete mode 100644 packages/nodejs/src-cares_wrap.h.patch diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index bb00e79c3..6d9a747a8 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -4,9 +4,9 @@ TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@termux" # Note: package build may fail on Github Actions CI due to out-of-memory # condition. It should be built locally instead. -TERMUX_PKG_VERSION=16.6.1 +TERMUX_PKG_VERSION=16.9.1 TERMUX_PKG_SRCURL=https://nodejs.org/dist/v${TERMUX_PKG_VERSION}/node-v${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=79b1ea058cc67f2a69462cd5f2467a1efe08c64299c053da70384ce1a0e3e557 +TERMUX_PKG_SHA256=97f50ec53c050e7ac97bdbe5586aaca380dd23064064c85a1f2017a35244131c # Note that we do not use a shared libuv to avoid an issue with the Android # linker, which does not use symbols of linked shared libraries when resolving # symbols on dlopen(). See https://github.com/termux/termux-packages/issues/462. diff --git a/packages/nodejs/deps-uv-src-unix-process.c.patch b/packages/nodejs/deps-uv-src-unix-process.c.patch index 7cdd7774c..592ce1c25 100644 --- a/packages/nodejs/deps-uv-src-unix-process.c.patch +++ b/packages/nodejs/deps-uv-src-unix-process.c.patch @@ -1,8 +1,8 @@ ---- ./deps/uv/src/unix/process.c 2021-06-03 07:15:30.000000000 +0530 -+++ ./deps/uv/src/unix/process.c.mod 2021-06-18 20:15:54.095642543 +0530 -@@ -281,27 +281,6 @@ - _exit(127); - } +--- ./deps/uv/src/unix/process.c 2021-09-10 22:55:12.000000000 +0530 ++++ ./deps/uv/src/unix/process.c.mod 2021-09-11 10:27:22.239600280 +0530 +@@ -283,23 +283,6 @@ + if (options->cwd != NULL && chdir(options->cwd)) + uv__write_errno(error_fd); - if (options->flags & (UV_PROCESS_SETUID | UV_PROCESS_SETGID)) { - /* When dropping privileges from root, the `setgroups` call will @@ -15,15 +15,11 @@ - SAVE_ERRNO(setgroups(0, NULL)); - } - -- if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) { -- uv__write_int(error_fd, UV__ERR(errno)); -- _exit(127); -- } +- if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) +- uv__write_errno(error_fd); - -- if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) { -- uv__write_int(error_fd, UV__ERR(errno)); -- _exit(127); -- } +- if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) +- uv__write_errno(error_fd); - if (options->env != NULL) { environ = options->env; diff --git a/packages/nodejs/src-cares_wrap.h.patch b/packages/nodejs/src-cares_wrap.h.patch deleted file mode 100644 index 76baf287c..000000000 --- a/packages/nodejs/src-cares_wrap.h.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- ./src/cares_wrap.h 2021-06-03 07:15:32.000000000 +0530 -+++ ./src/cares_wrap.h.mod 2021-06-19 08:34:10.153760365 +0530 -@@ -22,8 +22,7 @@ - # include - #endif // __POSIX__ - --#if defined(__ANDROID__) || \ -- defined(__MINGW32__) || \ -+#if defined(__MINGW32__) || \ - defined(__OpenBSD__) || \ - defined(_MSC_VER) - From a4fd54c600f0b20194dae5166a70fba8622ca7b3 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sat, 11 Sep 2021 11:39:16 +0530 Subject: [PATCH 04/14] Fix nameser include --- packages/nodejs/node.gyp.patch | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/nodejs/node.gyp.patch b/packages/nodejs/node.gyp.patch index c7b3e8770..435be2885 100644 --- a/packages/nodejs/node.gyp.patch +++ b/packages/nodejs/node.gyp.patch @@ -1,10 +1,18 @@ -diff -uNr node-v16.6.1/node.gyp node-v16.6.1.mod/node.gyp ---- node-v16.6.1/node.gyp 2021-08-03 05:54:26.000000000 +0000 -+++ node-v16.6.1.mod/node.gyp 2021-08-07 05:43:34.342341704 +0000 -@@ -1062,107 +1062,6 @@ +--- ./node.gyp 2021-09-10 22:55:14.000000000 +0530 ++++ ./node.gyp.mod 2021-09-11 12:25:09.026976247 +0530 +@@ -340,6 +340,7 @@ + + 'include_dirs': [ + 'src', ++ 'deps/cares/src/lib', + '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h + ], + 'dependencies': [ +@@ -1061,106 +1062,6 @@ + }], ], }, # fuzz_env - { +- { - 'target_name': 'cctest', - 'type': 'executable', - @@ -104,8 +112,6 @@ diff -uNr node-v16.6.1/node.gyp node-v16.6.1.mod/node.gyp - }], - ], - }, # cctest -- -- { - 'target_name': 'embedtest', - 'type': 'executable', + { + 'target_name': 'embedtest', From 9057a7a37f89ed53eb3d5db8e374cdd0d88ff07b Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sat, 11 Sep 2021 17:53:45 +0530 Subject: [PATCH 05/14] nodejs: Do not build embedtest --- packages/nodejs/node.gyp.patch | 62 ++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/packages/nodejs/node.gyp.patch b/packages/nodejs/node.gyp.patch index 435be2885..6e317ee0e 100644 --- a/packages/nodejs/node.gyp.patch +++ b/packages/nodejs/node.gyp.patch @@ -1,5 +1,5 @@ --- ./node.gyp 2021-09-10 22:55:14.000000000 +0530 -+++ ./node.gyp.mod 2021-09-11 12:25:09.026976247 +0530 ++++ ./node.gyp.mod 2021-09-11 17:48:42.567707131 +0530 @@ -340,6 +340,7 @@ 'include_dirs': [ @@ -8,7 +8,7 @@ '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h ], 'dependencies': [ -@@ -1061,106 +1062,6 @@ +@@ -1061,162 +1062,6 @@ }], ], }, # fuzz_env @@ -112,6 +112,62 @@ - }], - ], - }, # cctest +- +- { +- 'target_name': 'embedtest', +- 'type': 'executable', +- +- 'dependencies': [ +- '<(node_lib_target_name)', +- 'deps/histogram/histogram.gyp:histogram', +- 'deps/uvwasi/uvwasi.gyp:uvwasi', +- 'node_dtrace_header', +- 'node_dtrace_ustack', +- 'node_dtrace_provider', +- ], +- +- 'includes': [ +- 'node.gypi' +- ], +- +- 'include_dirs': [ +- 'src', +- 'tools/msvs/genfiles', +- 'deps/v8/include', +- 'deps/cares/include', +- 'deps/uv/include', +- 'deps/uvwasi/include', +- 'test/embedding', +- ], +- +- 'sources': [ +- 'src/node_snapshot_stub.cc', +- 'src/node_code_cache_stub.cc', +- 'test/embedding/embedtest.cc', +- ], +- +- 'conditions': [ +- ['OS=="solaris"', { +- 'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ] +- }], +- # Skip cctest while building shared lib node for Windows +- [ 'OS=="win" and node_shared=="true"', { +- 'type': 'none', +- }], +- [ 'node_shared=="true"', { +- 'xcode_settings': { +- 'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ], +- }, +- }], +- ['OS=="win"', { +- 'libraries': [ +- 'Dbghelp.lib', +- 'winmm.lib', +- 'Ws2_32.lib', +- ], +- }], +- ], +- }, # embedtest { - 'target_name': 'embedtest', + 'target_name': 'overlapped-checker', From 1d929353e3321740311b1886fc608beaaa407dc5 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sun, 12 Sep 2021 08:41:30 +0530 Subject: [PATCH 06/14] nodejs: Fix uv.gyp to also compile epoll.c This patch also needs to be sent upstream. The nodejs team has done this for linux but somehow didn't do it for android --- packages/nodejs/deps-uv-uv.gyp.patch | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/nodejs/deps-uv-uv.gyp.patch b/packages/nodejs/deps-uv-uv.gyp.patch index 756af45de..6be74d586 100644 --- a/packages/nodejs/deps-uv-uv.gyp.patch +++ b/packages/nodejs/deps-uv-uv.gyp.patch @@ -1,5 +1,5 @@ ---- ./deps/uv/uv.gyp 2021-06-03 07:15:30.000000000 +0530 -+++ ./deps/uv/uv.gyp.mod 2021-06-18 20:21:23.955642417 +0530 +--- ./deps/uv/uv.gyp 2021-09-12 08:37:13.451586303 +0530 ++++ ./deps/uv/uv.gyp.mod 2021-09-12 08:37:58.344924108 +0530 @@ -40,7 +40,7 @@ { 'target_name': 'libuv', @@ -18,3 +18,11 @@ 'conditions': [ ['OS == "linux"', { 'defines': [ '_POSIX_C_SOURCE=200112' ], +@@ -262,6 +262,7 @@ + 'src/unix/procfs-exepath.c', + 'src/unix/random-getrandom.c', + 'src/unix/random-sysctl-linux.c', ++ 'src/unix/epoll.c', + ], + 'link_settings': { + 'libraries': [ '-ldl' ], From 89e0dfb0c6a6d567752ace946a3201cd62294a50 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sun, 12 Sep 2021 16:00:50 +0530 Subject: [PATCH 07/14] nodejs: Add a hacky patch to fix host builds --- ...p-base-asm-x64-push_registers_asm.cc.patch | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 packages/nodejs/deps-v8-src-heap-base-asm-x64-push_registers_asm.cc.patch diff --git a/packages/nodejs/deps-v8-src-heap-base-asm-x64-push_registers_asm.cc.patch b/packages/nodejs/deps-v8-src-heap-base-asm-x64-push_registers_asm.cc.patch new file mode 100644 index 000000000..7861236cd --- /dev/null +++ b/packages/nodejs/deps-v8-src-heap-base-asm-x64-push_registers_asm.cc.patch @@ -0,0 +1,58 @@ +--- ./deps/v8/src/heap/base/asm/x64/push_registers_asm.cc 2021-09-10 22:55:12.000000000 +0530 ++++ ./deps/v8/src/heap/base/asm/x64/push_registers_asm.cc.mod 2021-09-12 16:03:58.444141027 +0530 +@@ -16,12 +16,15 @@ + // GN toolchain (e.g. ChromeOS) and not provide them. + // _WIN64 Defined as 1 when the compilation target is 64-bit ARM or x64. + // Otherwise, undefined. ++ ++#if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_X64) + #ifdef _WIN64 + + // We maintain 16-byte alignment at calls. There is an 8-byte return address + // on the stack and we push 232 bytes which maintains 16-byte stack alignment + // at the call. + // Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention ++ + asm(".globl PushAllRegistersAndIterateStack \n" + "PushAllRegistersAndIterateStack: \n" + // rbp is callee-saved. Maintain proper frame pointer for debugging. +@@ -104,3 +107,39 @@ + " ret \n"); + + #endif // !_WIN64 ++#else ++asm( ++#ifdef _WIN32 ++ ".globl _PushAllRegistersAndIterateStack \n" ++ "_PushAllRegistersAndIterateStack: \n" ++#else // !_WIN32 ++ ".globl PushAllRegistersAndIterateStack \n" ++ ".type PushAllRegistersAndIterateStack, %function \n" ++ ".hidden PushAllRegistersAndIterateStack \n" ++ "PushAllRegistersAndIterateStack: \n" ++#endif // !_WIN32 ++ // [ IterateStackCallback ] ++ // [ StackVisitor* ] ++ // [ Stack* ] ++ // [ ret ] ++ // ebp is callee-saved. Maintain proper frame pointer for debugging. ++ " push %ebp \n" ++ " movl %esp, %ebp \n" ++ " push %ebx \n" ++ " push %esi \n" ++ " push %edi \n" ++ // Save 3rd parameter (IterateStackCallback). ++ " movl 28(%esp), %ecx \n" ++ // Pass 3rd parameter as esp (stack pointer). ++ " push %esp \n" ++ // Pass 2nd parameter (StackVisitor*). ++ " push 28(%esp) \n" ++ // Pass 1st parameter (Stack*). ++ " push 28(%esp) \n" ++ " call *%ecx \n" ++ // Pop the callee-saved registers. ++ " addl $24, %esp \n" ++ // Restore rbp as it was used as frame pointer. ++ " pop %ebp \n" ++ " ret \n"); ++#endif From 988e8fd7a4edcd803a02a74fa09d692f60d678d3 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sun, 12 Sep 2021 19:00:25 +0530 Subject: [PATCH 08/14] nodejs: Link to atomic library when building for ia32 --- packages/nodejs/node.gyp.patch | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/nodejs/node.gyp.patch b/packages/nodejs/node.gyp.patch index 6e317ee0e..c61115054 100644 --- a/packages/nodejs/node.gyp.patch +++ b/packages/nodejs/node.gyp.patch @@ -1,5 +1,5 @@ ---- ./node.gyp 2021-09-10 22:55:14.000000000 +0530 -+++ ./node.gyp.mod 2021-09-11 17:48:42.567707131 +0530 +--- ./node.gyp.orig 2021-09-13 07:24:18.446321152 +0530 ++++ ./node.gyp 2021-09-13 08:02:04.399412339 +0530 @@ -340,6 +340,7 @@ 'include_dirs': [ @@ -171,3 +171,28 @@ { 'target_name': 'overlapped-checker', +@@ -1295,6 +1140,11 @@ + 'Ws2_32.lib', + ], + }], ++ ['target_arch=="ia32"', { ++ 'libraries': [ ++ '-latomic', ++ ], ++ }], + ], + }, # mkcodecache + { +@@ -1346,6 +1196,12 @@ + 'Ws2_32.lib', + ], + }], ++ ['target_arch=="ia32"', { ++ 'libraries': [ ++ '-latomic', ++ ], ++ 'cflags': ['-march=i686'], ++ }], + ], + }, # node_mksnapshot + ], # end targets From 06271bfea557c6f35eb4ba3b01f63a7da0eeda52 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Sun, 12 Sep 2021 19:00:46 +0530 Subject: [PATCH 09/14] Revert "nodejs: Remove x86_64 as blacklisted arch" I don't think much people use x86_64, and anyways it was already blacklisted, I might look into it later --- packages/nodejs/build.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index 6d9a747a8..c663ee5c3 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -18,6 +18,18 @@ TERMUX_PKG_SUGGESTS="clang, make, pkg-config, python" TERMUX_PKG_RM_AFTER_INSTALL="lib/node_modules/npm/html lib/node_modules/npm/make.bat share/systemtap lib/dtrace" TERMUX_PKG_BUILD_IN_SRC=true TERMUX_PKG_HOSTBUILD=true +# Build fails on x86_64 with: +# g++ -rdynamic -m64 -pthread -m64 -fPIC -o /home/builder/.termux-build/nodejs/src/out/Release/mksnapshot ... +# /usr/bin/ld: /home/builder/.termux-build/nodejs/src/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/api/api.o: +# in function `v8::TryHandleWebAssemblyTrapPosix(int, siginfo_t*, void*)': +# api.cc:(.text._ZN2v829TryHandleWebAssemblyTrapPosixEiP9siginfo_tPv+0x5): +# undefined reference to `v8::internal::trap_handler::TryHandleSignal(int, siginfo_t*, void*)' +# /usr/bin/ld: /home/builder/.termux-build/nodejs/src/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/trap-handler/handler-outside.o: +# in function `v8::internal::trap_handler::EnableTrapHandler(bool)': +# handler-outside.cc:(.text._ZN2v88internal12trap_handler17EnableTrapHandlerEb+0x25): +# undefined reference to `v8::internal::trap_handler::RegisterDefaultTrapHandler()' +# collect2: error: ld returned 1 exit status +TERMUX_PKG_BLACKLISTED_ARCHES="x86_64" termux_step_post_get_source() { # Prevent caching of host build: From cee109645a81c7ec82ac2abab88b4fed06f519d8 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Mon, 13 Sep 2021 15:59:41 +0530 Subject: [PATCH 10/14] nodejs: Final try to fix i686 --- packages/nodejs/build.sh | 2 +- packages/nodejs/node.gyp.patch | 74 +++++++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index c663ee5c3..7e2a3ac8d 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -78,7 +78,7 @@ termux_step_configure() { export CXX_host=g++ export LINK_host="g++ -Wl,--no-as-needed -ldl -lz" - LDFLAGS+=" -Wl,--no-as-needed -ldl" + LDFLAGS+=" -Wl,--no-as-needed -ldl -latomic" # See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv. ./configure \ diff --git a/packages/nodejs/node.gyp.patch b/packages/nodejs/node.gyp.patch index c61115054..8f2bbb6a9 100644 --- a/packages/nodejs/node.gyp.patch +++ b/packages/nodejs/node.gyp.patch @@ -1,5 +1,5 @@ ---- ./node.gyp.orig 2021-09-13 07:24:18.446321152 +0530 -+++ ./node.gyp 2021-09-13 08:02:04.399412339 +0530 +--- ./node.gyp.orig 2021-09-13 15:57:45.411848965 +0530 ++++ ./node.gyp 2021-09-13 15:58:53.811848939 +0530 @@ -340,6 +340,7 @@ 'include_dirs': [ @@ -171,28 +171,66 @@ { 'target_name': 'overlapped-checker', -@@ -1295,6 +1140,11 @@ +@@ -1295,59 +1140,13 @@ 'Ws2_32.lib', ], }], +- ], +- }, # mkcodecache +- { +- 'target_name': 'node_mksnapshot', +- 'type': 'executable', +- +- 'dependencies': [ +- '<(node_lib_target_name)', +- 'deps/histogram/histogram.gyp:histogram', +- 'deps/uvwasi/uvwasi.gyp:uvwasi', +- ], +- +- 'includes': [ +- 'node.gypi' +- ], +- +- 'include_dirs': [ +- 'src', +- 'tools/msvs/genfiles', +- 'deps/v8/include', +- 'deps/cares/include', +- 'deps/uv/include', +- 'deps/uvwasi/include', +- ], +- +- 'defines': [ 'NODE_WANT_INTERNALS=1' ], +- +- 'sources': [ +- 'src/node_snapshot_stub.cc', +- 'src/node_code_cache_stub.cc', +- 'tools/snapshot/node_mksnapshot.cc', +- ], +- +- 'conditions': [ +- [ 'node_use_openssl=="true"', { +- 'defines': [ +- 'HAVE_OPENSSL=1', +- ], +- }], +- ['v8_enable_inspector==1', { +- 'defines': [ +- 'HAVE_INSPECTOR=1', +- ], +- }], +- ['OS=="win"', { + ['target_arch=="ia32"', { -+ 'libraries': [ + 'libraries': [ +- 'Dbghelp.lib', +- 'winmm.lib', +- 'Ws2_32.lib', + '-latomic', -+ ], -+ }], - ], - }, # mkcodecache - { -@@ -1346,6 +1196,12 @@ - 'Ws2_32.lib', ], }], -+ ['target_arch=="ia32"', { -+ 'libraries': [ -+ '-latomic', -+ ], -+ 'cflags': ['-march=i686'], -+ }], ], - }, # node_mksnapshot +- }, # node_mksnapshot ++ }, # mkcodecache ], # end targets + + 'conditions': [ From 896be775f5f1393db25f48f85d94de7d07756452 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Tue, 14 Sep 2021 06:57:56 +0530 Subject: [PATCH 11/14] Try LDFLAGS as proposed by Grimler --- packages/nodejs/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index 7e2a3ac8d..6fd504755 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -78,7 +78,7 @@ termux_step_configure() { export CXX_host=g++ export LINK_host="g++ -Wl,--no-as-needed -ldl -lz" - LDFLAGS+=" -Wl,--no-as-needed -ldl -latomic" + LDFLAGS+=" -Wl,--no-as-needed -ldl -u __atomic_fetch_add_8 -u __atomic_load_8 -u __atomic_compare_exchange_8 -latomic" # See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv. ./configure \ From 2b1446db889c9f5fdcf4f0e95af32f1ebb66d60b Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Tue, 14 Sep 2021 09:10:14 +0530 Subject: [PATCH 12/14] Remove unnecesary patches --- packages/nodejs/Makefile.patch | 10 ---------- packages/nodejs/deps-v8-BUILD.gn.patch | 11 ----------- 2 files changed, 21 deletions(-) delete mode 100644 packages/nodejs/Makefile.patch delete mode 100644 packages/nodejs/deps-v8-BUILD.gn.patch diff --git a/packages/nodejs/Makefile.patch b/packages/nodejs/Makefile.patch deleted file mode 100644 index 1690efcb6..000000000 --- a/packages/nodejs/Makefile.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- ./Makefile 2021-09-10 11:00:12.544728388 +0530 -+++ ./Makefile.mod 2021-09-10 11:04:27.388422344 +0530 -@@ -19,6 +19,7 @@ - PWD = $(CURDIR) - BUILD_WITH ?= make - FIND ?= find -+V8_ARCH = $(DESTCPU) - - ifdef JOBS - PARALLEL_ARGS = -j $(JOBS) diff --git a/packages/nodejs/deps-v8-BUILD.gn.patch b/packages/nodejs/deps-v8-BUILD.gn.patch deleted file mode 100644 index 66ac0f097..000000000 --- a/packages/nodejs/deps-v8-BUILD.gn.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ./deps/v8/BUILD.gn 2021-06-03 07:15:30.000000000 +0530 -+++ ./deps/v8/BUILD.gn.mod 2021-07-17 17:32:54.134091233 +0530 -@@ -17,6 +17,8 @@ - import("gni/snapshot_toolchain.gni") - import("gni/v8.gni") - -+v8_target_cpu = getenv("DEST_CPU") -+ - # Specifies if the target build is a simulator build. Comparing target cpu - # with v8 target cpu to not affect simulator builds for making cross-compile - # snapshots. From 04c742b575dbaa304cd22a4f9c1899a88ac411f2 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Tue, 14 Sep 2021 09:15:42 +0530 Subject: [PATCH 13/14] Improve the way how LDFLAGS is modified The -u flags are required only for i686. So why add them to all archs? --- packages/nodejs/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index 6fd504755..d6abd3af5 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -65,6 +65,7 @@ termux_step_configure() { DEST_CPU="arm" elif [ $TERMUX_ARCH = "i686" ]; then DEST_CPU="ia32" + LDFLAGS+=" -u __atomic_fetch_add_8 -u __atomic_load_8 -u __atomic_compare_exchange_8 -latomic" elif [ $TERMUX_ARCH = "aarch64" ]; then DEST_CPU="arm64" elif [ $TERMUX_ARCH = "x86_64" ]; then @@ -78,8 +79,7 @@ termux_step_configure() { export CXX_host=g++ export LINK_host="g++ -Wl,--no-as-needed -ldl -lz" - LDFLAGS+=" -Wl,--no-as-needed -ldl -u __atomic_fetch_add_8 -u __atomic_load_8 -u __atomic_compare_exchange_8 -latomic" - + LDFLAGS+=" -ldl" # See note above TERMUX_PKG_DEPENDS why we do not use a shared libuv. ./configure \ --prefix=$TERMUX_PREFIX \ From 3b50563b7ca64667f26e2faf6b538f87271f1c3a Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Tue, 14 Sep 2021 11:11:49 +0530 Subject: [PATCH 14/14] nodejs: Update description and declare myself as maintainer --- packages/nodejs/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodejs/build.sh b/packages/nodejs/build.sh index d6abd3af5..0e3aef782 100644 --- a/packages/nodejs/build.sh +++ b/packages/nodejs/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://nodejs.org/ -TERMUX_PKG_DESCRIPTION="Platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications" +TERMUX_PKG_DESCRIPTION="Open Source, cross-platform JavaScript runtime environment" TERMUX_PKG_LICENSE="MIT" -TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_MAINTAINER="Yaksh Bariya " # Note: package build may fail on Github Actions CI due to out-of-memory # condition. It should be built locally instead. TERMUX_PKG_VERSION=16.9.1