diff --git a/.github/workflows/build-alpine.yml b/.github/workflows/build-alpine.yml index d1290683..b2d475a1 100644 --- a/.github/workflows/build-alpine.yml +++ b/.github/workflows/build-alpine.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18, 19] + target-node: [14, 16, 18, 19, 20] target-arch: [x64, arm64] include: - target-arch: x64 diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 469b311f..7a567627 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18, 19] + target-node: [14, 16, 18, 19, 20] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/build-linuxstatic.yml b/.github/workflows/build-linuxstatic.yml index 58c9ae11..1c1af06a 100644 --- a/.github/workflows/build-linuxstatic.yml +++ b/.github/workflows/build-linuxstatic.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18, 19] + target-node: [14, 16, 18, 19, 20] target-arch: [x64, arm64, armv7] include: - target-arch: x64 diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index ff23ec9e..50c4fc21 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18, 19] + target-node: [14, 16, 18, 19, 20] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 3f1c4d64..fc05f24b 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - target-node: [14, 16, 18, 19] + target-node: [14, 16, 18, 19, 20] target-arch: [x64, arm64] steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19c4ed98..96253591 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: [12, 14, 16, 18, 19] # match patched node versions + node-version: [12, 14, 16, 18, 19, 20] # match patched node versions os: [ubuntu-latest] # Skip macos-latest, windows-latest for now runs-on: ${{ matrix.os }} diff --git a/lib/verify.ts b/lib/verify.ts index fc3d3a82..fd0f2754 100644 --- a/lib/verify.ts +++ b/lib/verify.ts @@ -54,6 +54,9 @@ const script = ` } else if (modules === 111) { // no cpu features anymore + } else + if (modules === 115) { + // no cpu features anymore } else { assert(false, modules); } @@ -91,6 +94,8 @@ const script = ` if (modules === 108) { } else if (modules === 111) { + } else + if (modules === 115) { } else { assert(false, modules); } diff --git a/patches/node.v20.10.0.cpp.patch b/patches/node.v20.10.0.cpp.patch new file mode 100644 index 00000000..69607cb0 --- /dev/null +++ b/patches/node.v20.10.0.cpp.patch @@ -0,0 +1,579 @@ +diff --git a/common.gypi b/common.gypi +index 4589f51517..97555b4c0b 100644 +--- a/common.gypi ++++ b/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 a/configure.py b/configure.py +index 62f041ce52..4688ec0fdd 100755 +--- a/configure.py ++++ b/configure.py +@@ -1270,7 +1270,6 @@ def configure_node(o): + + # Enable branch protection for arm64 + if target_arch == 'arm64': +- o['cflags']+=['-msign-return-address=all'] + o['variables']['arm_fpu'] = options.arm_fpu or 'neon' + + if options.node_snapshot_main is not None: +diff --git a/deps/v8/include/v8-initialization.h b/deps/v8/include/v8-initialization.h +index d3e35d6ec5..6e9bbe3849 100644 +--- a/deps/v8/include/v8-initialization.h ++++ b/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 a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc +index a91dfc271c..a4cd4eeb31 100644 +--- a/deps/v8/src/api/api.cc ++++ b/deps/v8/src/api/api.cc +@@ -806,6 +806,28 @@ 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::v8_flags.lazy; ++ i::v8_flags.lazy = false; ++ save_predictable = i::v8_flags.predictable; ++ i::v8_flags.predictable = true; ++} ++ ++void V8::DisableCompilationForSourcelessUse() { ++ i::v8_flags.lazy = save_lazy; ++ i::v8_flags.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 a/deps/v8/src/codegen/compiler.cc b/deps/v8/src/codegen/compiler.cc +index 31c5acceeb..56cad8671f 100644 +--- a/deps/v8/src/codegen/compiler.cc ++++ b/deps/v8/src/codegen/compiler.cc +@@ -3475,7 +3475,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 a/deps/v8/src/objects/js-function.cc b/deps/v8/src/objects/js-function.cc +index 94f7a672a7..57bb3fc7f1 100644 +--- a/deps/v8/src/objects/js-function.cc ++++ b/deps/v8/src/objects/js-function.cc +@@ -1280,6 +1280,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 a/deps/v8/src/objects/shared-function-info-inl.h b/deps/v8/src/objects/shared-function-info-inl.h +index 5621b15d98..722e1d18cb 100644 +--- a/deps/v8/src/objects/shared-function-info-inl.h ++++ b/deps/v8/src/objects/shared-function-info-inl.h +@@ -635,6 +635,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 a/deps/v8/src/parsing/parsing.cc b/deps/v8/src/parsing/parsing.cc +index 8c55a6fb6e..70bf82a57d 100644 +--- a/deps/v8/src/parsing/parsing.cc ++++ b/deps/v8/src/parsing/parsing.cc +@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle