From bb13d372b2f6415b7c0d53bbccbbf648b9d3c7c5 Mon Sep 17 00:00:00 2001 From: Amir Valizadeh Date: Tue, 8 Oct 2024 15:53:29 -0700 Subject: [PATCH] upgraded nodejs version to 20.18.0 --- .gitignore | 1 + Dockerfile.centos7 | 2 +- Dockerfile.centos7.arm64 | 2 +- azure-pipelines.yml | 10 +++---- build-builder.sh | 7 +++-- src/NodeBuilder.js | 11 ++++---- src/patch/20.18.0/fs-event.c.patch | 11 ++++++++ src/patch/20.18.0/no_rand_on_glibc.patch | 24 ++++++++++++++++ src/patch/20.18.0/node.cc.patch | 17 +++++++++++ src/patch/20.18.0/node.gyp.patch | 13 +++++++++ .../20.18.0/run_third_party_main.js.patch | 17 +++++++++++ src/patch/20.18.0/vcbuild.bat.patch | 28 +++++++++++++++++++ 12 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 src/patch/20.18.0/fs-event.c.patch create mode 100644 src/patch/20.18.0/no_rand_on_glibc.patch create mode 100644 src/patch/20.18.0/node.cc.patch create mode 100644 src/patch/20.18.0/node.gyp.patch create mode 100644 src/patch/20.18.0/run_third_party_main.js.patch create mode 100644 src/patch/20.18.0/vcbuild.bat.patch diff --git a/.gitignore b/.gitignore index cbe8773..37a0d55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ build/ cache/ +.DS_Store diff --git a/Dockerfile.centos7 b/Dockerfile.centos7 index edeaedc..1ad90c1 100644 --- a/Dockerfile.centos7 +++ b/Dockerfile.centos7 @@ -15,7 +15,7 @@ RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \ # use node 10 as it's guaranteed to run on CentOS6 RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \ - yum install -y devtoolset-8 python36 wget patch && \ + yum install -y devtoolset-10 python36 wget patch && \ wget -q https://nodejs.org/dist/v10.23.0/node-v10.23.0-linux-x64.tar.gz && \ tar -xf node-v10.23.0-linux-x64.tar.gz && \ rm node-v10.23.0-linux-x64.tar.gz && \ diff --git a/Dockerfile.centos7.arm64 b/Dockerfile.centos7.arm64 index b693b80..85f256c 100644 --- a/Dockerfile.centos7.arm64 +++ b/Dockerfile.centos7.arm64 @@ -15,7 +15,7 @@ RUN sed -i 's|mirror.centos.org/centos|vault.centos.org/altarch|g' /etc/yum.repo # use node 10 as it's guaranteed to run on CentOS6 RUN yum-config-manager --enable rhel-server-rhscl-7-rpms && \ - yum install -y devtoolset-8 python36 wget patch && \ + yum install -y devtoolset-10 python36 wget patch && \ wget -q https://nodejs.org/dist/v10.23.0/node-v10.23.0-linux-arm64.tar.gz && \ gunzip node-v10.23.0-linux-arm64.tar.gz && tar xf node-v10.23.0-linux-arm64.tar && rm node-v10.23.0-linux-arm64.tar && \ ln -s /node-v10.23.0-linux-arm64/bin/node /bin/node && \ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 594d4d1..e8a798a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,27 +6,27 @@ jobs: linux_arm64: imageName: 'ubuntu-20.04' arch: 'linux/arm64' - node: '18.20.4' + node: '20.18.0' linux_amd64: imageName: 'ubuntu-20.04' arch: 'linux/amd64' - node: '18.20.4' + node: '20.18.0' ptrcompress: false linux_amd64_ptrc: imageName: 'ubuntu-20.04' arch: 'linux/amd64' - node: '18.20.4' + node: '20.18.0' ptrcompress: true windows_2019: imageName: 'windows-2019' - node: '18.20.4' + node: '20.18.0' ptrcompress: false windows_2019_ptrc: imageName: 'windows-2019' - node: '18.20.4' + node: '20.18.0' ptrcompress: true # mac: diff --git a/build-builder.sh b/build-builder.sh index 9d77e0f..ea364db 100755 --- a/build-builder.sh +++ b/build-builder.sh @@ -5,6 +5,7 @@ if [ $(docker buildx ls | grep js2bin-builder | wc -l) -eq 0 ]; then fi docker run --rm --privileged multiarch/qemu-user-static --reset -p yes docker buildx use js2bin-builder -docker buildx build -t "cribl/js2bin-builder:latest-nonx64" --platform linux/arm64/v8 --push -f Dockerfile.centos7.arm64 . -docker build -t "cribl/js2bin-builder:latest" -f Dockerfile.centos7 . -docker push "cribl/js2bin-builder:latest" +BUILDER_IMAGE_VERSION="2" +docker buildx build -t "cribl/js2bin-builder:${BUILDER_IMAGE_VERSION}-nonx64" --platform linux/arm64/v8 --push -f Dockerfile.centos7.arm64 . +docker build -t "cribl/js2bin-builder:${BUILDER_IMAGE_VERSION}" -f Dockerfile.centos7 . +docker push "cribl/js2bin-builder:${BUILDER_IMAGE_VERSION}" diff --git a/src/NodeBuilder.js b/src/NodeBuilder.js index 8938be6..144df46 100644 --- a/src/NodeBuilder.js +++ b/src/NodeBuilder.js @@ -67,6 +67,7 @@ class NodeJsBuilder { this.cacheDir = join(cwd || process.cwd(), 'cache'); this.resultFile = isWindows ? join(this.nodeSrcDir, 'Release', 'node.exe') : join(this.nodeSrcDir, 'out', 'Release', 'node'); this.placeHolderSizeMB = -1; + this.builderImageVersion = 2; } static platform() { @@ -228,26 +229,26 @@ class NodeJsBuilder { } buildInContainer() { - const containerTag = 'cribl/js2bin-builder:latest'; + const containerTag = `cribl/js2bin-builder:${this.builderImageVersion}`; return runCommand( 'docker', ['run', '-v', `${process.cwd()}:/js2bin/`, '-t', containerTag, '/bin/bash', '-c', - `source /opt/rh/devtoolset-8/enable && cd /js2bin && npm install && ./js2bin.js --ci --node=${this.version} --size=${this.placeHolderSizeMB}MB` + `source /opt/rh/devtoolset-10/enable && cd /js2bin && npm install && ./js2bin.js --ci --node=${this.version} --size=${this.placeHolderSizeMB}MB` ] ); } buildInContainerNonX64(arch) { - const containerTag = 'cribl/js2bin-builder:latest-nonx64'; + const containerTag = `cribl/js2bin-builder:${this.builderImageVersion}-nonx64`; return runCommand( 'docker', ['run', '--platform', arch, '-v', `${process.cwd()}:/js2bin/`, '-t', containerTag, '/bin/bash', '-c', - `source /opt/rh/devtoolset-8/enable && cd /js2bin && npm install && ./js2bin.js --ci --node=${this.version} --size=${this.placeHolderSizeMB}MB` + `source /opt/rh/devtoolset-10/enable && cd /js2bin && npm install && ./js2bin.js --ci --node=${this.version} --size=${this.placeHolderSizeMB}MB` ] ); } @@ -258,7 +259,7 @@ class NodeJsBuilder { // 4. process mainAppFile (gzip, base64 encode it) - could be a placeholder file // 5. kick off ./configure & build buildFromSource(uploadBuild, cache, container, arch, ptrCompression) { - const makeArgs = isWindows ? ['x64', 'noetw', 'no-cctest'] : [`-j${os.cpus().length}`]; + const makeArgs = isWindows ? ['x64', 'no-cctest'] : [`-j${os.cpus().length}`]; const configArgs = []; if(ptrCompression) { if(isWindows) makeArgs.push('v8_ptr_compress'); diff --git a/src/patch/20.18.0/fs-event.c.patch b/src/patch/20.18.0/fs-event.c.patch new file mode 100644 index 0000000..47430c6 --- /dev/null +++ b/src/patch/20.18.0/fs-event.c.patch @@ -0,0 +1,11 @@ +--- a/deps/uv/src/win/fs-event.c ++++ b/deps/uv/src/win/fs-event.c +@@ -266,6 +266,8 @@ short_path_done: + } + + dir_to_watch = dir; ++ uv__free(short_path); ++ short_path = NULL; + uv__free(pathw); + pathw = NULL; + } diff --git a/src/patch/20.18.0/no_rand_on_glibc.patch b/src/patch/20.18.0/no_rand_on_glibc.patch new file mode 100644 index 0000000..6c31891 --- /dev/null +++ b/src/patch/20.18.0/no_rand_on_glibc.patch @@ -0,0 +1,24 @@ +disable usage of + +--- deps/cares/config/linux/ares_config.h ++++ deps/cares/config/linux/ares_config.h +@@ -116,7 +116,9 @@ + #define HAVE_GETNAMEINFO 1 + + /* Define to 1 if you have `getrandom` */ ++#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 25 + #define HAVE_GETRANDOM 1 ++#endif + + /* Define to 1 if you have `getservbyport_r` */ + #define HAVE_GETSERVBYPORT_R 1 +@@ -329,7 +331,9 @@ + #define HAVE_SYS_PARAM_H 1 + + /* Define to 1 if you have the header file. */ ++#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 25 + #define HAVE_SYS_RANDOM_H 1 ++#endif + + /* Define to 1 if you have the header file. */ + #define HAVE_SYS_SELECT_H 1 diff --git a/src/patch/20.18.0/node.cc.patch b/src/patch/20.18.0/node.cc.patch new file mode 100644 index 0000000..8781895 --- /dev/null +++ b/src/patch/20.18.0/node.cc.patch @@ -0,0 +1,17 @@ +--- src/node.cc ++++ src/node.cc +@@ -377,6 +377,14 @@ MaybeLocal StartExecution(Environment* env, StartExecutionCallback cb) { + return env->RunSnapshotDeserializeMain(); + } + ++ // To allow people to extend Node in different ways, this hook allows ++ // one to drop a file lib/_third_party_main.js into the build ++ // directory which will be executed instead of Node's normal loading. ++ if (env->builtin_loader()->Exists("_third_party_main")) { ++ return StartExecution(env, "internal/main/run_third_party_main"); ++ } ++ ++ + if (env->worker_context() != nullptr) { + return StartExecution(env, "internal/main/worker_thread"); + } diff --git a/src/patch/20.18.0/node.gyp.patch b/src/patch/20.18.0/node.gyp.patch new file mode 100644 index 0000000..7b01be2 --- /dev/null +++ b/src/patch/20.18.0/node.gyp.patch @@ -0,0 +1,13 @@ +disable building of cctest as it (a) it fails to build due to align_alloc and (b) it is just a waste of time + +--- node.gyp ++++ node.gyp +@@ -1144,7 +1144,7 @@ + }, # fuzz_strings + { + 'target_name': 'cctest', +- 'type': 'executable', ++ 'type': 'none', + + 'dependencies': [ + '<(node_lib_target_name)', diff --git a/src/patch/20.18.0/run_third_party_main.js.patch b/src/patch/20.18.0/run_third_party_main.js.patch new file mode 100644 index 0000000..3114bef --- /dev/null +++ b/src/patch/20.18.0/run_third_party_main.js.patch @@ -0,0 +1,17 @@ +--- /dev/null ++++ lib/internal/main/run_third_party_main.js +@@ -0,0 +1,14 @@ ++'use strict'; ++ ++const { ++ prepareMainThreadExecution, ++ markBootstrapComplete ++} = require('internal/process/pre_execution'); ++ ++prepareMainThreadExecution(); ++markBootstrapComplete(); ++ ++// Legacy _third_party_main.js support ++process.nextTick(() => { ++ require('_third_party_main'); ++}); diff --git a/src/patch/20.18.0/vcbuild.bat.patch b/src/patch/20.18.0/vcbuild.bat.patch new file mode 100644 index 0000000..2aceed0 --- /dev/null +++ b/src/patch/20.18.0/vcbuild.bat.patch @@ -0,0 +1,28 @@ +expose option for configuring pointer compression + +--- vcbuild.bat ++++ vcbuild.bat +@@ -67,6 +67,7 @@ set no_shared_roheap= + set doc= + set extra_msbuild_args= + set exit_code=0 ++set v8_ptr_compress= + + :next-arg + if "%1"=="" goto args-done +@@ -139,6 +140,7 @@ if /i "%1"=="cctest" set cctest=1&goto arg-ok + if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok + if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok + if /i "%1"=="doc" set doc=1&goto arg-ok ++if /i "%1"=="v8_ptr_compress" set v8_ptr_compress=1&goto arg-ok + if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:out\%config%\node.binlog&goto arg-ok + + echo Error: invalid command line option `%1`. +@@ -196,6 +198,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp + if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm + if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap + if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose ++if defined v8_ptr_compress set configure_flags=%configure_flags% --experimental-enable-pointer-compression + if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling + + if not exist "%~dp0deps\icu" goto no-depsicu