From b6e9dfcaab8c9c29c2e63ee7646be44a57d99c88 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Sun, 5 Feb 2023 19:59:59 -0700 Subject: [PATCH 1/3] patches: Add patch for node 19.6 --- .github/workflows/arm64-alpine.yml | 2 +- .github/workflows/arm64-linux.yml | 2 +- .github/workflows/arm64-linuxstatic.yml | 2 +- .github/workflows/arm64-macos.yml | 2 +- .github/workflows/build-alpine.yml | 2 +- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-linuxstatic.yml | 2 +- .github/workflows/build-macos.yml | 2 +- .github/workflows/build-windows.yml | 2 +- .github/workflows/ci.yml | 2 +- patches/node.v19.6.0.cpp.patch | 548 ++++++++++++++++++++++++ patches/patches.json | 1 + 12 files changed, 559 insertions(+), 10 deletions(-) create mode 100644 patches/node.v19.6.0.cpp.patch diff --git a/.github/workflows/arm64-alpine.yml b/.github/workflows/arm64-alpine.yml index eb4753b8..902c1a0c 100644 --- a/.github/workflows/arm64-alpine.yml +++ b/.github/workflows/arm64-alpine.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/arm64-linux.yml b/.github/workflows/arm64-linux.yml index 111967a7..724a47f9 100644 --- a/.github/workflows/arm64-linux.yml +++ b/.github/workflows/arm64-linux.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/arm64-linuxstatic.yml b/.github/workflows/arm64-linuxstatic.yml index 246cfb21..a74b081e 100644 --- a/.github/workflows/arm64-linuxstatic.yml +++ b/.github/workflows/arm64-linuxstatic.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18] + target-node: [14, 16, 18, 19] target-arch: [arm64] include: - target-arch: arm64 diff --git a/.github/workflows/arm64-macos.yml b/.github/workflows/arm64-macos.yml index a3997be5..ec7198e6 100644 --- a/.github/workflows/arm64-macos.yml +++ b/.github/workflows/arm64-macos.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-alpine.yml b/.github/workflows/build-alpine.yml index fd75fbc3..cf5054ac 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: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 10bd0577..8b04a008 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: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-linuxstatic.yml b/.github/workflows/build-linuxstatic.yml index 5967f3a8..99879c19 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: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index af30eb42..d1b0c953 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: [14, 16, 18] + target-node: [14, 16, 18, 19] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index dbdf9cf3..c158033b 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: [14, 16, 18] + target-node: [14, 16, 18, 19] target-arch: [x64, arm64] steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28028f77..4b956fd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false # prevent test to stop if one fails matrix: - node-version: [10, 12, 14, 16, 18] + node-version: [10, 12, 14, 16, 18, 19] os: [ubuntu-latest] # Skip macos-latest, windows-latest for now runs-on: ${{ matrix.os }} diff --git a/patches/node.v19.6.0.cpp.patch b/patches/node.v19.6.0.cpp.patch new file mode 100644 index 00000000..1272adc2 --- /dev/null +++ b/patches/node.v19.6.0.cpp.patch @@ -0,0 +1,548 @@ +diff --git node/common.gypi node/common.gypi +index b3718cff39..6a4a664ba0 100644 +--- node/common.gypi ++++ node/common.gypi +@@ -174,7 +174,7 @@ + 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD) + }], + ['llvm_version=="0.0"', { +- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC ++ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC + }, { + 'lto': ' -flto ', # Clang + }], +diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h +index d3e35d6ec5..6e9bbe3849 100644 +--- node/deps/v8/include/v8-initialization.h ++++ node/deps/v8/include/v8-initialization.h +@@ -89,6 +89,10 @@ class V8_EXPORT V8 { + static void SetFlagsFromCommandLine(int* argc, 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(); + +diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc +index a4a4381614..2998f3c49b 100644 +--- node/deps/v8/src/api/api.cc ++++ node/deps/v8/src/api/api.cc +@@ -683,6 +683,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) +diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc +index 5431deb83e..d11f04ccac 100644 +--- node/deps/v8/src/codegen/compiler.cc ++++ node/deps/v8/src/codegen/compiler.cc +@@ -3497,7 +3497,7 @@ MaybeHandle GetSharedFunctionInfoForScriptImpl( + maybe_script = lookup_result.script(); + maybe_result = lookup_result.toplevel_sfi(); + is_compiled_scope = lookup_result.is_compiled_scope(); +- 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(); +diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc +index 62fe309a47..f1875ce023 100644 +--- node/deps/v8/src/objects/js-function.cc ++++ node/deps/v8/src/objects/js-function.cc +@@ -1245,6 +1245,9 @@ Handle JSFunction::ToString(Handle function) { + Handle maybe_class_positions = JSReceiver::GetDataProperty( + isolate, 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(); +diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h +index 43ef0d3d17..79b774463f 100644 +--- node/deps/v8/src/objects/shared-function-info-inl.h ++++ node/deps/v8/src/objects/shared-function-info-inl.h +@@ -637,6 +637,14 @@ bool SharedFunctionInfo::ShouldFlushCode( + } + 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 (IsStressFlushingEnabled(code_flush_mode)) return true; + + BytecodeArray bytecode = BytecodeArray::cast(data); +diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc +index 8c55a6fb6e..70bf82a57d 100644 +--- node/deps/v8/src/parsing/parsing.cc ++++ node/deps/v8/src/parsing/parsing.cc +@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle