diff --git a/.github/workflows/build-alpine.yml b/.github/workflows/build-alpine.yml index 1ddd9737..62f4fe22 100644 --- a/.github/workflows/build-alpine.yml +++ b/.github/workflows/build-alpine.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12, 14] + target-node: [10, 12, 14, 16] target-arch: [x64, arm64] include: - target-arch: x64 @@ -41,7 +41,13 @@ jobs: run: | tar xvf ../out.tar root/pkg-fetch/dist + - name: Check if binary is compiled + id: check_file + run: | + (test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false + - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-alpine-${{ matrix.target-arch }} path: root/pkg-fetch/dist/* diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 0b55a4c5..103d2a89 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12, 14] + target-node: [10, 12, 14, 16] steps: - uses: actions/checkout@v2 @@ -39,7 +39,13 @@ jobs: run: | tar xvf ../out.tar root/pkg-fetch/dist + - name: Check if binary is compiled + id: check_file + run: | + (test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false + - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-linux-x64 path: root/pkg-fetch/dist/* @@ -50,7 +56,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12, 14] + target-node: [10, 12, 14, 16] steps: - uses: actions/checkout@v2 @@ -65,7 +71,7 @@ jobs: - run: yarn install - - run: yarn start --force-build --node-range node${{ matrix.target-node }} --arch arm64 --output dist + - run: yarn start --node-range node${{ matrix.target-node }} --arch arm64 --output dist env: CC: /usr/bin/aarch64-linux-gnu-gcc-8 CXX: /usr/bin/aarch64-linux-gnu-g++-8 @@ -79,7 +85,13 @@ jobs: NM_host: /usr/bin/nm READELF_host: /usr/bin/readelf + - name: Check if binary is compiled + id: check_file + run: | + (test -f dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false + - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-linux-arm64 path: dist/* diff --git a/.github/workflows/build-linuxstatic.yml b/.github/workflows/build-linuxstatic.yml index 199f1139..b7896e21 100644 --- a/.github/workflows/build-linuxstatic.yml +++ b/.github/workflows/build-linuxstatic.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12, 14] + target-node: [10, 12, 14, 16] target-arch: [x64, arm64] include: - target-arch: x64 @@ -41,7 +41,13 @@ jobs: run: | tar xvf ../out.tar root/pkg-fetch/dist + - name: Check if binary is compiled + id: check_file + run: | + (test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false + - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-linuxstatic-${{ matrix.target-arch }} path: root/pkg-fetch/dist/* diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 8826ef2c..38e48181 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12, 14] + target-node: [10, 12, 14, 16] steps: - uses: actions/checkout@v2 @@ -26,9 +26,15 @@ jobs: - run: yarn install - - run: yarn start --force-build --node-range node${{ matrix.target-node }} --output dist + - run: yarn start --node-range node${{ matrix.target-node }} --output dist + + - name: Check if binary is compiled + id: check_file + run: | + (test -f dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-macos-x64 path: dist/* diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 37e734a1..b75141e4 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [8, 10, 12] + target-node: [10, 12] target-arch: [x64] steps: @@ -29,11 +29,17 @@ jobs: - run: choco install nasm - - run: yarn start --force-build --node-range node${{ matrix.target-node }} --arch ${{ matrix.target-arch }} --output dist + - run: yarn start --node-range node${{ matrix.target-node }} --arch ${{ matrix.target-arch }} --output dist env: PKG_BUILD_PATH: build + - name: Check if binary is compiled + id: check_file + run: | + if (Test-Path -Path dist\\*.sha256sum -PathType Leaf) { echo "::set-output name=EXISTS::true" } else { echo "::set-output name=EXISTS::false" } + - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-windows-${{ matrix.target-arch }} path: dist\\* @@ -44,7 +50,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14] + target-node: [14, 16] target-arch: [x64, arm64] steps: @@ -59,9 +65,15 @@ jobs: - run: choco install nasm - - run: yarn start --force-build --node-range node${{ matrix.target-node }} --arch ${{ matrix.target-arch }} --output dist + - run: yarn start --node-range node${{ matrix.target-node }} --arch ${{ matrix.target-arch }} --output dist + + - name: Check if binary is compiled + id: check_file + run: | + if (Test-Path -Path dist\\*.sha256sum -PathType Leaf) { echo "::set-output name=EXISTS::true" } else { echo "::set-output name=EXISTS::false" } - uses: actions/upload-artifact@v2 + if: steps.check_file.outputs.EXISTS == 'true' with: name: node${{ matrix.target-node }}-windows-${{ matrix.target-arch }} path: dist\\* diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 99532aff..855e88ff 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -35,4 +35,4 @@ COPY . ./ RUN yarn install -RUN yarn start --force-build --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist +RUN yarn start --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist diff --git a/Dockerfile.linux b/Dockerfile.linux index 96ef367c..f3eef3d9 100644 --- a/Dockerfile.linux +++ b/Dockerfile.linux @@ -19,4 +19,4 @@ RUN npm install -g yarn RUN yarn install -RUN yarn start --force-build --node-range $PKG_FETCH_OPTION_n --output dist +RUN yarn start --node-range $PKG_FETCH_OPTION_n --output dist diff --git a/patches/node.v16.0.0.cpp.patch b/patches/node.v16.0.0.cpp.patch new file mode 100644 index 00000000..a7db9893 --- /dev/null +++ b/patches/node.v16.0.0.cpp.patch @@ -0,0 +1,509 @@ +--- node/common.gypi ++++ node/common.gypi +@@ -164,7 +164,7 @@ + 'v8_enable_handle_zapping': 0, + 'pgo_generate': ' -fprofile-generate ', + 'pgo_use': ' -fprofile-use -fprofile-correction ', +- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', ++ 'lto': ' -flto=4 -ffat-lto-objects ', + 'conditions': [ + ['node_shared != "true"', { + 'MSVC_runtimeType': 0 # MultiThreaded (/MT) +--- node/deps/v8/include/v8.h ++++ node/deps/v8/include/v8.h +@@ -9934,6 +9934,10 @@ class V8_EXPORT V8 { + char** argv, + bool remove_flags); + ++ static void EnableCompilationForSourcelessUse(); ++ static void DisableCompilationForSourcelessUse(); ++ static void FixSourcelessScript(Isolate* v8_isolate, Local script); ++ + /** Get the version string. */ + static const char* GetVersion(); + +--- node/deps/v8/src/api/api.cc ++++ node/deps/v8/src/api/api.cc +@@ -628,6 +628,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { + HelpOptions(HelpOptions::kDontExit)); + } + ++bool save_lazy; ++bool save_predictable; ++ ++void V8::EnableCompilationForSourcelessUse() { ++ save_lazy = i::FLAG_lazy; ++ i::FLAG_lazy = false; ++ save_predictable = i::FLAG_predictable; ++ i::FLAG_predictable = true; ++} ++ ++void V8::DisableCompilationForSourcelessUse() { ++ i::FLAG_lazy = save_lazy; ++ i::FLAG_predictable = save_predictable; ++} ++ ++void V8::FixSourcelessScript(Isolate* v8_isolate, Local unbound_script) { ++ auto isolate = reinterpret_cast(v8_isolate); ++ auto function_info = ++ i::Handle::cast(Utils::OpenHandle(*unbound_script)); ++ i::Handle script(i::Script::cast(function_info->script()), isolate); ++ script->set_source(i::ReadOnlyRoots(isolate).undefined_value()); ++} ++ + RegisteredExtension* RegisteredExtension::first_extension_ = nullptr; + + RegisteredExtension::RegisteredExtension(std::unique_ptr extension) +--- node/deps/v8/src/codegen/compiler.cc ++++ node/deps/v8/src/codegen/compiler.cc +@@ -2840,7 +2840,7 @@ MaybeHandle Compiler::GetSharedFunctionInfoForScript( + source, script_details.name_obj, script_details.line_offset, + script_details.column_offset, origin_options, isolate->native_context(), + language_mode); +- if (!maybe_result.is_null()) { ++ if (!maybe_result.is_null() && source_length) { + compile_timer.set_hit_isolate_cache(); + } else if (can_consume_code_cache) { + compile_timer.set_consuming_code_cache(); +--- node/deps/v8/src/objects/js-function.cc ++++ node/deps/v8/src/objects/js-function.cc +@@ -905,6 +905,9 @@ Handle JSFunction::ToString(Handle function) { + Handle maybe_class_positions = JSReceiver::GetDataProperty( + function, isolate->factory()->class_positions_symbol()); + if (maybe_class_positions->IsClassPositions()) { ++ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) { ++ return isolate->factory()->NewStringFromAsciiChecked("class {}"); ++ } + ClassPositions class_positions = + ClassPositions::cast(*maybe_class_positions); + int start_position = class_positions.start(); +--- node/deps/v8/src/objects/shared-function-info-inl.h ++++ node/deps/v8/src/objects/shared-function-info-inl.h +@@ -568,6 +568,14 @@ bool SharedFunctionInfo::ShouldFlushBytecode(BytecodeFlushMode mode) { + Object data = function_data(kAcquireLoad); + if (!data.IsBytecodeArray()) return false; + ++ Object script_obj = script(); ++ if (!script_obj.IsUndefined()) { ++ Script script = Script::cast(script_obj); ++ if (script.source().IsUndefined()) { ++ return false; ++ } ++ } ++ + if (mode == BytecodeFlushMode::kStressFlushBytecode) return true; + + BytecodeArray bytecode = BytecodeArray::cast(data); +--- node/deps/v8/src/parsing/parsing.cc ++++ node/deps/v8/src/parsing/parsing.cc +@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle