diff --git a/patches/node.v14.20.0.cpp.patch b/patches/node.v14.21.1.cpp.patch similarity index 98% rename from patches/node.v14.20.0.cpp.patch rename to patches/node.v14.21.1.cpp.patch index 617f6c33..d6454d30 100644 --- a/patches/node.v14.20.0.cpp.patch +++ b/patches/node.v14.21.1.cpp.patch @@ -315,7 +315,7 @@ index 0000000000..fb2d47f52b Environment* env = static_cast(data); --- node/src/node.cc +++ node/src/node.cc -@@ -386,6 +386,9 @@ MaybeLocal Environment::BootstrapNode() { +@@ -390,6 +390,9 @@ MaybeLocal Environment::BootstrapNode() { return scope.EscapeMaybe(result); } @@ -325,7 +325,7 @@ index 0000000000..fb2d47f52b MaybeLocal Environment::RunBootstrapping() { EscapableHandleScope scope(isolate_); -@@ -409,6 +412,8 @@ MaybeLocal Environment::RunBootstrapping() { +@@ -413,6 +416,8 @@ MaybeLocal Environment::RunBootstrapping() { set_has_run_bootstrapping_code(true); @@ -334,7 +334,7 @@ index 0000000000..fb2d47f52b return scope.Escape(result); } -@@ -573,13 +578,6 @@ static struct { +@@ -577,13 +582,6 @@ static struct { inline void PlatformInit() { #ifdef __POSIX__ @@ -348,7 +348,7 @@ index 0000000000..fb2d47f52b // Make sure file descriptors 0-2 are valid before we start logging anything. for (auto& s : stdio) { const int fd = &s - stdio; -@@ -595,10 +593,6 @@ inline void PlatformInit() { +@@ -599,10 +597,6 @@ inline void PlatformInit() { ABORT(); } diff --git a/patches/node.v16.16.0.cpp.patch b/patches/node.v16.18.1.cpp.patch similarity index 93% rename from patches/node.v16.16.0.cpp.patch rename to patches/node.v16.18.1.cpp.patch index 35b34885..ac5d8155 100644 --- a/patches/node.v16.16.0.cpp.patch +++ b/patches/node.v16.18.1.cpp.patch @@ -130,7 +130,7 @@ if (Checksum(ChecksummedContent()) != c) return CHECKSUM_MISMATCH; --- node/lib/child_process.js +++ node/lib/child_process.js -@@ -163,7 +163,7 @@ function fork(modulePath, args = [], options) { +@@ -166,7 +166,7 @@ function fork(modulePath, args = [], options) { options.execPath = options.execPath || process.execPath; options.shell = false; @@ -189,20 +189,21 @@ index 0000000000..fb2d47f52b +}()); --- node/lib/internal/bootstrap/pre_execution.js +++ node/lib/internal/bootstrap/pre_execution.js -@@ -25,7 +25,12 @@ const { Buffer } = require('buffer'); +@@ -26,8 +26,13 @@ const { Buffer } = require('buffer'); const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes; const assert = require('internal/assert'); +let _alreadyPrepared = false; + - function prepareMainThreadExecution(expandArgv1 = false) { + function prepareMainThreadExecution(expandArgv1 = false, + initialzeModules = true) { + if (_alreadyPrepared === true) return; + _alreadyPrepared = true; + + refreshRuntimeOptions(); + // TODO(joyeecheung): this is also necessary for workers when they deserialize - // this toggle from the snapshot. - reconnectZeroFillToggle(); -@@ -100,7 +105,8 @@ function patchProcessObject(expandArgv1) { +@@ -119,7 +124,8 @@ function patchProcessObject(expandArgv1) { process.argv[0] = process.execPath; if (expandArgv1 && process.argv[1] && @@ -214,7 +215,7 @@ index 0000000000..fb2d47f52b try { --- node/lib/internal/modules/cjs/loader.js +++ node/lib/internal/modules/cjs/loader.js -@@ -86,7 +86,7 @@ const fs = require('fs'); +@@ -92,7 +92,7 @@ const fs = require('fs'); const internalFS = require('internal/fs/utils'); const path = require('path'); const { sep } = path; @@ -267,8 +268,8 @@ index 0000000000..fb2d47f52b Environment* env = static_cast(data); --- node/src/node.cc +++ node/src/node.cc -@@ -473,6 +473,8 @@ MaybeLocal StartExecution(Environment* env, StartExecutionCallback cb) { - return scope.EscapeMaybe(cb(info)); +@@ -481,6 +481,8 @@ MaybeLocal StartExecution(Environment* env, StartExecutionCallback cb) { + return env->RunSnapshotDeserializeMain(); } + StartExecution(env, "internal/bootstrap/pkg"); @@ -276,7 +277,7 @@ index 0000000000..fb2d47f52b if (env->worker_context() != nullptr) { return StartExecution(env, "internal/main/worker_thread"); } -@@ -583,13 +585,6 @@ static struct { +@@ -599,13 +601,6 @@ static struct { inline void PlatformInit() { #ifdef __POSIX__ @@ -290,7 +291,7 @@ index 0000000000..fb2d47f52b // Make sure file descriptors 0-2 are valid before we start logging anything. for (auto& s : stdio) { const int fd = &s - stdio; -@@ -605,10 +600,6 @@ inline void PlatformInit() { +@@ -621,10 +616,6 @@ inline void PlatformInit() { ABORT(); } @@ -311,7 +312,7 @@ index 0000000000..fb2d47f52b using v8::Value; using v8::WeakCallbackInfo; using v8::WeakCallbackType; -@@ -709,11 +710,12 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -711,11 +712,12 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { Local cached_data_buf; bool produce_cached_data = false; Local parsing_context = context; @@ -325,7 +326,7 @@ index 0000000000..fb2d47f52b CHECK(args[2]->IsNumber()); line_offset = args[2].As()->Value(); CHECK(args[3]->IsNumber()); -@@ -732,6 +734,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -734,6 +736,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { CHECK_NOT_NULL(sandbox); parsing_context = sandbox->context(); } @@ -333,7 +334,7 @@ index 0000000000..fb2d47f52b } ContextifyScript* contextify_script = -@@ -784,6 +787,10 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -785,6 +788,10 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { ShouldNotAbortOnUncaughtScope no_abort_scope(env); Context::Scope scope(parsing_context); @@ -344,8 +345,8 @@ index 0000000000..fb2d47f52b MaybeLocal v8_script = ScriptCompiler::CompileUnboundScript( isolate, &source, -@@ -800,6 +807,13 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { - contextify_script); +@@ -799,6 +806,13 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { + "ContextifyScript::New"); return; } + @@ -358,7 +359,7 @@ index 0000000000..fb2d47f52b contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked()); Local env_context = env->context(); -@@ -826,6 +840,11 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -825,6 +839,11 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { env->cached_data_produced_string(), Boolean::New(isolate, cached_data_produced)).Check(); } @@ -367,9 +368,9 @@ index 0000000000..fb2d47f52b + V8::DisableCompilationForSourcelessUse(); + } + - TRACE_EVENT_NESTABLE_ASYNC_END0( - TRACING_CATEGORY_NODE2(vm, script), - "ContextifyScript::New", + TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New"); + } + --- node/src/node_main.cc +++ node/src/node_main.cc @@ -22,6 +22,8 @@ @@ -481,7 +482,7 @@ index 0000000000..fb2d47f52b +} --- node/src/node_options.cc +++ node/src/node_options.cc -@@ -254,6 +254,7 @@ void Parse( +@@ -275,6 +275,7 @@ void Parse( // TODO(addaleax): Make that unnecessary. DebugOptionsParser::DebugOptionsParser() { diff --git a/patches/node.v18.5.0.cpp.patch b/patches/node.v18.12.1.cpp.patch similarity index 88% rename from patches/node.v18.5.0.cpp.patch rename to patches/node.v18.12.1.cpp.patch index b33c73ca..bfdb1edc 100644 --- a/patches/node.v18.5.0.cpp.patch +++ b/patches/node.v18.12.1.cpp.patch @@ -24,7 +24,7 @@ --- node/deps/v8/src/api/api.cc +++ node/deps/v8/src/api/api.cc -@@ -706,6 +706,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { +@@ -709,6 +709,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { HelpOptions(HelpOptions::kDontExit)); } @@ -140,7 +140,7 @@ if (payload_length > max_payload_length) { --- node/lib/child_process.js +++ node/lib/child_process.js -@@ -160,7 +160,7 @@ function fork(modulePath, args = [], options) { +@@ -164,7 +164,7 @@ function fork(modulePath, args = [], options) { throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio'); } @@ -157,7 +157,7 @@ index 00000000000..fb2d47f52b6 + +const { + prepareMainThreadExecution -+} = require('internal/bootstrap/pre_execution'); ++} = require('internal/process/pre_execution'); + +prepareMainThreadExecution(true); + @@ -197,12 +197,12 @@ index 00000000000..fb2d47f52b6 + } + }()); +}()); ---- node/lib/internal/bootstrap/pre_execution.js -+++ node/lib/internal/bootstrap/pre_execution.js -@@ -29,8 +29,13 @@ const { - } = require('internal/errors').codes; - const assert = require('internal/assert'); - +--- node/lib/internal/process/pre_execution.js ++++ node/lib/internal/process/pre_execution.js +@@ -33,8 +33,13 @@ const { + isBuildingSnapshot, + } = require('v8').startupSnapshot; + +let _alreadyPrepared = false; + function prepareMainThreadExecution(expandArgv1 = false, @@ -211,9 +211,9 @@ index 00000000000..fb2d47f52b6 + _alreadyPrepared = true; + refreshRuntimeOptions(); - + // TODO(joyeecheung): this is also necessary for workers when they deserialize -@@ -119,7 +124,8 @@ function patchProcessObject(expandArgv1) { +@@ -128,7 +133,8 @@ function patchProcessObject(expandArgv1) { process.argv[0] = process.execPath; if (expandArgv1 && process.argv[1] && @@ -223,7 +223,7 @@ index 00000000000..fb2d47f52b6 // Expand process.argv[1] into a full path. const path = require('path'); try { -@@ -574,6 +580,7 @@ function loadPreloadModules() { +@@ -589,6 +595,7 @@ function loadPreloadModules() { // For user code, we preload modules if `-r` is passed const preloadModules = getOptionValue('--require'); if (preloadModules && preloadModules.length > 0) { @@ -233,7 +233,7 @@ index 00000000000..fb2d47f52b6 _preloadModules --- node/lib/internal/modules/cjs/loader.js +++ node/lib/internal/modules/cjs/loader.js -@@ -86,7 +86,7 @@ const fs = require('fs'); +@@ -92,7 +92,7 @@ const fs = require('fs'); const internalFS = require('internal/fs/utils'); const path = require('path'); const { sep } = path; @@ -275,7 +275,7 @@ index 00000000000..fb2d47f52b6 } --- node/src/inspector_agent.cc +++ node/src/inspector_agent.cc -@@ -690,8 +690,6 @@ bool Agent::Start(const std::string& path, +@@ -693,8 +693,6 @@ bool Agent::Start(const std::string& path, StartIoThreadAsyncCallback)); uv_unref(reinterpret_cast(&start_io_thread_async)); start_io_thread_async.data = this; @@ -286,8 +286,8 @@ index 00000000000..fb2d47f52b6 Environment* env = static_cast(data); --- node/src/node.cc +++ node/src/node.cc -@@ -482,6 +482,8 @@ MaybeLocal StartExecution(Environment* env, StartExecutionCallback cb) { - return scope.EscapeMaybe(cb(info)); +@@ -458,6 +458,8 @@ MaybeLocal StartExecution(Environment* env, StartExecutionCallback cb) { + return env->RunSnapshotDeserializeMain(); } + StartExecution(env, "internal/bootstrap/pkg"); @@ -295,31 +295,21 @@ index 00000000000..fb2d47f52b6 if (env->worker_context() != nullptr) { return StartExecution(env, "internal/main/worker_thread"); } -@@ -600,13 +602,6 @@ static struct { +@@ -628,14 +630,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) { + } - inline void PlatformInit() { - #ifdef __POSIX__ + if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) { -#if HAVE_INSPECTOR -- sigset_t sigmask; -- sigemptyset(&sigmask); -- sigaddset(&sigmask, SIGUSR1); -- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr); +- sigset_t sigmask; +- sigemptyset(&sigmask); +- sigaddset(&sigmask, SIGUSR1); +- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr); +- CHECK_EQ(err, 0); -#endif // HAVE_INSPECTOR - - // Make sure file descriptors 0-2 are valid before we start logging anything. - for (auto& s : stdio) { - const int fd = &s - stdio; -@@ -622,10 +617,6 @@ inline void PlatformInit() { - ABORT(); + ResetSignalHandlers(); } --#if HAVE_INSPECTOR -- CHECK_EQ(err, 0); --#endif // HAVE_INSPECTOR -- - // TODO(addaleax): NODE_SHARED_MODE does not really make sense here. - #ifndef NODE_SHARED_MODE - // Restore signal dispositions, the parent process may have changed them. --- node/src/node_contextify.cc +++ node/src/node_contextify.cc @@ -74,6 +74,7 @@ using v8::ScriptOrModule; @@ -330,7 +320,7 @@ index 00000000000..fb2d47f52b6 using v8::Value; using v8::WeakCallbackInfo; using v8::WeakCallbackType; -@@ -701,11 +702,12 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -741,11 +742,12 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { Local cached_data_buf; bool produce_cached_data = false; Local parsing_context = context; @@ -344,7 +334,7 @@ index 00000000000..fb2d47f52b6 CHECK(args[2]->IsNumber()); line_offset = args[2].As()->Value(); CHECK(args[3]->IsNumber()); -@@ -724,6 +726,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -764,6 +766,7 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { CHECK_NOT_NULL(sandbox); parsing_context = sandbox->context(); } @@ -352,7 +342,7 @@ index 00000000000..fb2d47f52b6 } ContextifyScript* contextify_script = -@@ -775,6 +778,10 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -814,6 +817,10 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { ShouldNotAbortOnUncaughtScope no_abort_scope(env); Context::Scope scope(parsing_context); @@ -363,7 +353,7 @@ index 00000000000..fb2d47f52b6 MaybeLocal v8_script = ScriptCompiler::CompileUnboundScript( isolate, &source, -@@ -789,6 +796,13 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -828,6 +835,13 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { "ContextifyScript::New"); return; } @@ -377,7 +367,7 @@ index 00000000000..fb2d47f52b6 contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked()); Local env_context = env->context(); -@@ -815,6 +829,11 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { +@@ -854,6 +868,11 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { env->cached_data_produced_string(), Boolean::New(isolate, cached_data_produced)).Check(); } @@ -400,7 +390,7 @@ index 00000000000..fb2d47f52b6 #ifdef _WIN32 #include #include -@@ -84,7 +86,7 @@ int wmain(int argc, wchar_t* wargv[]) { +@@ -84,12 +86,95 @@ int wmain(int argc, wchar_t* wargv[]) { } argv[argc] = nullptr; // Now that conversion is done, we can finally start. @@ -409,10 +399,8 @@ index 00000000000..fb2d47f52b6 } #else // UNIX -@@ -124,6 +126,88 @@ int main(int argc, char* argv[]) { - // calls elsewhere in the program (e.g., any logging from V8.) - setvbuf(stdout, nullptr, _IONBF, 0); - setvbuf(stderr, nullptr, _IONBF, 0); + + int main(int argc, char* argv[]) { + return reorder(argc, argv); +} +#endif @@ -468,6 +456,7 @@ index 00000000000..fb2d47f52b6 +#elif defined(__GNUC__) +__attribute__((optimize(0))) #endif ++ +int load_baked(char** nargv) { + int c = 1; + @@ -500,7 +489,7 @@ index 00000000000..fb2d47f52b6 +} --- node/src/node_options.cc +++ node/src/node_options.cc -@@ -275,6 +275,7 @@ void Parse( +@@ -299,6 +299,7 @@ void Parse( // TODO(addaleax): Make that unnecessary. DebugOptionsParser::DebugOptionsParser() { diff --git a/patches/patches.json b/patches/patches.json index c3bb657a..5cd314fa 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -1,7 +1,7 @@ { - "v18.5.0": ["node.v18.5.0.cpp.patch"], - "v16.16.0": ["node.v16.16.0.cpp.patch"], - "v14.20.0": ["node.v14.20.0.cpp.patch"], + "v18.12.1": ["node.v18.12.1.cpp.patch"], + "v16.18.1": ["node.v16.18.1.cpp.patch"], + "v14.21.1": ["node.v14.21.1.cpp.patch"], "v12.22.11": ["node.v12.22.11.cpp.patch"], "v10.24.1": ["node.v10.24.1.cpp.patch"], "v8.17.0": ["node.v8.17.0.cpp.patch"]