@yao-pkg/pkg-fetch 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,581 @@
1
+ diff --git node/common.gypi node/common.gypi
2
+ index 782c871cff..c379e36569 100644
3
+ --- node/common.gypi
4
+ +++ node/common.gypi
5
+ @@ -174,7 +174,7 @@
6
+ 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
7
+ }],
8
+ ['llvm_version=="0.0"', {
9
+ - 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
10
+ + 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
11
+ }, {
12
+ 'lto': ' -flto ', # Clang
13
+ }],
14
+ diff --git node/configure.py node/configure.py
15
+ index 62c01aaf6a..2913940692 100755
16
+ --- node/configure.py
17
+ +++ node/configure.py
18
+ @@ -1288,9 +1288,7 @@ def configure_node(o):
19
+
20
+ o['variables']['want_separate_host_toolset'] = int(cross_compiling)
21
+
22
+ - # Enable branch protection for arm64
23
+ if target_arch == 'arm64':
24
+ - o['cflags']+=['-msign-return-address=all']
25
+ o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
26
+
27
+ if options.node_snapshot_main is not None:
28
+ diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h
29
+ index 3d59c73f7c..00b2de4524 100644
30
+ --- node/deps/v8/include/v8-initialization.h
31
+ +++ node/deps/v8/include/v8-initialization.h
32
+ @@ -89,6 +89,10 @@ class V8_EXPORT V8 {
33
+ static void SetFlagsFromCommandLine(int* argc, char** argv,
34
+ bool remove_flags);
35
+
36
+ + static void EnableCompilationForSourcelessUse();
37
+ + static void DisableCompilationForSourcelessUse();
38
+ + static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
39
+ +
40
+ /** Get the version string. */
41
+ static const char* GetVersion();
42
+
43
+ diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
44
+ index 8d224bea2e..8402afc0fb 100644
45
+ --- node/deps/v8/src/api/api.cc
46
+ +++ node/deps/v8/src/api/api.cc
47
+ @@ -709,6 +709,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
48
+ HelpOptions(HelpOptions::kDontExit));
49
+ }
50
+
51
+ +bool save_lazy;
52
+ +bool save_predictable;
53
+ +
54
+ +void V8::EnableCompilationForSourcelessUse() {
55
+ + save_lazy = i::FLAG_lazy;
56
+ + i::FLAG_lazy = false;
57
+ + save_predictable = i::FLAG_predictable;
58
+ + i::FLAG_predictable = true;
59
+ +}
60
+ +
61
+ +void V8::DisableCompilationForSourcelessUse() {
62
+ + i::FLAG_lazy = save_lazy;
63
+ + i::FLAG_predictable = save_predictable;
64
+ +}
65
+ +
66
+ +void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
67
+ + auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
68
+ + auto function_info =
69
+ + i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
70
+ + i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
71
+ + script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
72
+ +}
73
+ +
74
+ RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
75
+
76
+ RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
77
+ diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
78
+ index a0d2e45ffc..3f29eb7cce 100644
79
+ --- node/deps/v8/src/codegen/compiler.cc
80
+ +++ node/deps/v8/src/codegen/compiler.cc
81
+ @@ -3026,7 +3026,7 @@ MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
82
+ // First check per-isolate compilation cache.
83
+ maybe_result =
84
+ compilation_cache->LookupScript(source, script_details, language_mode);
85
+ - if (!maybe_result.is_null()) {
86
+ + if (!maybe_result.is_null() && source_length) {
87
+ compile_timer.set_hit_isolate_cache();
88
+ } else if (can_consume_code_cache) {
89
+ compile_timer.set_consuming_code_cache();
90
+ diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
91
+ index e8898a10eb..1ca40655cb 100644
92
+ --- node/deps/v8/src/objects/js-function.cc
93
+ +++ node/deps/v8/src/objects/js-function.cc
94
+ @@ -1207,6 +1207,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
95
+ Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
96
+ isolate, function, isolate->factory()->class_positions_symbol());
97
+ if (maybe_class_positions->IsClassPositions()) {
98
+ + if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
99
+ + return isolate->factory()->NewStringFromAsciiChecked("class {}");
100
+ + }
101
+ ClassPositions class_positions =
102
+ ClassPositions::cast(*maybe_class_positions);
103
+ int start_position = class_positions.start();
104
+ diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h
105
+ index 6fffdf6b19..34cc72217b 100644
106
+ --- node/deps/v8/src/objects/shared-function-info-inl.h
107
+ +++ node/deps/v8/src/objects/shared-function-info-inl.h
108
+ @@ -636,6 +636,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
109
+ }
110
+ if (!data.IsBytecodeArray()) return false;
111
+
112
+ + Object script_obj = script();
113
+ + if (!script_obj.IsUndefined()) {
114
+ + Script script = Script::cast(script_obj);
115
+ + if (script.source().IsUndefined()) {
116
+ + return false;
117
+ + }
118
+ + }
119
+ +
120
+ if (IsStressFlushingEnabled(code_flush_mode)) return true;
121
+
122
+ BytecodeArray bytecode = BytecodeArray::cast(data);
123
+ diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
124
+ index add1f203f0..333a715ff0 100644
125
+ --- node/deps/v8/src/parsing/parsing.cc
126
+ +++ node/deps/v8/src/parsing/parsing.cc
127
+ @@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
128
+ Isolate* isolate, ReportStatisticsMode mode) {
129
+ DCHECK(info->flags().is_toplevel());
130
+ DCHECK_NULL(info->literal());
131
+ + if (String::cast(script->source()).IsUndefined(isolate)) return false;
132
+
133
+ VMState<PARSER> state(isolate);
134
+
135
+ @@ -76,6 +77,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
136
+
137
+ // Create a character stream for the parser.
138
+ Handle<Script> script(Script::cast(shared_info->script()), isolate);
139
+ + if (String::cast(script->source()).IsUndefined(isolate)) return false;
140
+ Handle<String> source(String::cast(script->source()), isolate);
141
+ isolate->counters()->total_parse_size()->Increment(source->length());
142
+ std::unique_ptr<Utf16CharacterStream> stream(
143
+ diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
144
+ index 618cf9e975..64a57e8afe 100644
145
+ --- node/deps/v8/src/snapshot/code-serializer.cc
146
+ +++ node/deps/v8/src/snapshot/code-serializer.cc
147
+ @@ -615,11 +615,7 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
148
+ }
149
+
150
+ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
151
+ - uint32_t expected_source_hash) const {
152
+ - uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
153
+ - if (source_hash != expected_source_hash) {
154
+ - return SerializedCodeSanityCheckResult::kSourceMismatch;
155
+ - }
156
+ + uint32_t) const {
157
+ return SerializedCodeSanityCheckResult::kSuccess;
158
+ }
159
+
160
+ @@ -636,10 +632,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource()
161
+ if (version_hash != Version::Hash()) {
162
+ return SerializedCodeSanityCheckResult::kVersionMismatch;
163
+ }
164
+ - uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
165
+ - if (flags_hash != FlagList::Hash()) {
166
+ - return SerializedCodeSanityCheckResult::kFlagsMismatch;
167
+ - }
168
+ uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
169
+ uint32_t max_payload_length = this->size_ - kHeaderSize;
170
+ if (payload_length > max_payload_length) {
171
+ diff --git node/lib/child_process.js node/lib/child_process.js
172
+ index 55e6b781cd..2a499d6d5f 100644
173
+ --- node/lib/child_process.js
174
+ +++ node/lib/child_process.js
175
+ @@ -167,7 +167,7 @@ function fork(modulePath, args = [], options) {
176
+ throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
177
+ }
178
+
179
+ - return spawn(options.execPath, args, options);
180
+ + return module.exports.spawn(options.execPath, args, options);
181
+ }
182
+
183
+ function _forkChild(fd, serializationMode) {
184
+ diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
185
+ new file mode 100644
186
+ index 0000000000..e97e9e524c
187
+ --- /dev/null
188
+ +++ node/lib/internal/bootstrap/pkg.js
189
+ @@ -0,0 +1,49 @@
190
+ +'use strict';
191
+ +
192
+ +const {
193
+ + prepareWorkerThreadExecution,
194
+ + prepareMainThreadExecution
195
+ +} = require('internal/process/pre_execution');
196
+ +
197
+ +if (internalBinding('worker').isMainThread) {
198
+ + prepareMainThreadExecution(true);
199
+ +} else {
200
+ + prepareWorkerThreadExecution();
201
+ +}
202
+ +
203
+ +(function () {
204
+ + var __require__ = require;
205
+ + var fs = __require__('fs');
206
+ + var vm = __require__('vm');
207
+ + function readPrelude (fd) {
208
+ + var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
209
+ + var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
210
+ + var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
211
+ + var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
212
+ + if (!PRELUDE_POSITION) {
213
+ + // no prelude - remove entrypoint from argv[1]
214
+ + process.argv.splice(1, 1);
215
+ + return { undoPatch: true };
216
+ + }
217
+ + var prelude = Buffer.alloc(PRELUDE_SIZE);
218
+ + var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
219
+ + if (read !== PRELUDE_SIZE) {
220
+ + console.error('Pkg: Error reading from file.');
221
+ + process.exit(1);
222
+ + }
223
+ + var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
224
+ + var fn = s.runInThisContext();
225
+ + return fn(process, __require__,
226
+ + console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
227
+ + }
228
+ + (function () {
229
+ + var fd = fs.openSync(process.execPath, 'r');
230
+ + var result = readPrelude(fd);
231
+ + if (result && result.undoPatch) {
232
+ + var bindingFs = process.binding('fs');
233
+ + fs.internalModuleStat = bindingFs.internalModuleStat;
234
+ + fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
235
+ + fs.closeSync(fd);
236
+ + }
237
+ + }());
238
+ +}());
239
+ diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
240
+ index 42e5cc5010..7c4ec56082 100644
241
+ --- node/lib/internal/modules/cjs/loader.js
242
+ +++ node/lib/internal/modules/cjs/loader.js
243
+ @@ -94,7 +94,7 @@ const fs = require('fs');
244
+ const internalFS = require('internal/fs/utils');
245
+ const path = require('path');
246
+ const { sep } = path;
247
+ -const { internalModuleStat } = internalBinding('fs');
248
+ +const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
249
+ const packageJsonReader = require('internal/modules/package_json_reader');
250
+ const { safeGetenv } = internalBinding('credentials');
251
+ const {
252
+ diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
253
+ index 09eb12bd15..2d2f196737 100644
254
+ --- node/lib/internal/modules/package_json_reader.js
255
+ +++ node/lib/internal/modules/package_json_reader.js
256
+ @@ -1,7 +1,7 @@
257
+ 'use strict';
258
+
259
+ const { SafeMap } = primordials;
260
+ -const { internalModuleReadJSON } = internalBinding('fs');
261
+ +const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
262
+ const { pathToFileURL } = require('url');
263
+ const { toNamespacedPath } = require('path');
264
+
265
+ diff --git node/lib/internal/process/pre_execution.js node/lib/internal/process/pre_execution.js
266
+ index 44a9183d77..3d2268c612 100644
267
+ --- node/lib/internal/process/pre_execution.js
268
+ +++ node/lib/internal/process/pre_execution.js
269
+ @@ -33,7 +33,12 @@ const {
270
+ isBuildingSnapshot,
271
+ } = require('v8').startupSnapshot;
272
+
273
+ +let _alreadyPrepared = false;
274
+ +
275
+ function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
276
+ + if (_alreadyPrepared === true) return;
277
+ + _alreadyPrepared = true;
278
+ +
279
+ prepareExecution({
280
+ expandArgv1,
281
+ initializeModules,
282
+ @@ -143,7 +148,8 @@ function patchProcessObject(expandArgv1) {
283
+ process.argv[0] = process.execPath;
284
+
285
+ if (expandArgv1 && process.argv[1] &&
286
+ - !StringPrototypeStartsWith(process.argv[1], '-')) {
287
+ + !StringPrototypeStartsWith(process.argv[1], '-') &&
288
+ + process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
289
+ // Expand process.argv[1] into a full path.
290
+ const path = require('path');
291
+ try {
292
+ @@ -598,6 +604,7 @@ function loadPreloadModules() {
293
+ // For user code, we preload modules if `-r` is passed
294
+ const preloadModules = getOptionValue('--require');
295
+ if (preloadModules && preloadModules.length > 0) {
296
+ + assert(false, '--require is not supported');
297
+ const {
298
+ Module: {
299
+ _preloadModules
300
+ diff --git node/lib/vm.js node/lib/vm.js
301
+ index ec91c8a265..5bb649a377 100644
302
+ --- node/lib/vm.js
303
+ +++ node/lib/vm.js
304
+ @@ -79,6 +79,7 @@ class Script extends ContextifyScript {
305
+ produceCachedData = false,
306
+ importModuleDynamically,
307
+ [kParsingContext]: parsingContext,
308
+ + sourceless = false,
309
+ } = options;
310
+
311
+ validateString(filename, 'options.filename');
312
+ @@ -103,7 +104,8 @@ class Script extends ContextifyScript {
313
+ columnOffset,
314
+ cachedData,
315
+ produceCachedData,
316
+ - parsingContext);
317
+ + parsingContext,
318
+ + sourceless);
319
+ } catch (e) {
320
+ throw e; /* node-do-not-add-exception-line */
321
+ }
322
+ diff --git node/node.gyp node/node.gyp
323
+ index 0b5c3ff5ba..09776d4b1f 100644
324
+ --- node/node.gyp
325
+ +++ node/node.gyp
326
+ @@ -112,6 +112,9 @@
327
+ },
328
+
329
+ 'conditions': [
330
+ + ['target_arch=="arm64"', {
331
+ + 'cflags': ['-msign-return-address=all'], # Pointer authentication.
332
+ + }],
333
+ ['OS=="aix"', {
334
+ 'ldflags': [
335
+ '-Wl,-bnoerrmsg',
336
+ diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
337
+ index 91e7beeaa0..43a8a5d7c6 100644
338
+ --- node/src/inspector_agent.cc
339
+ +++ node/src/inspector_agent.cc
340
+ @@ -692,8 +692,6 @@ bool Agent::Start(const std::string& path,
341
+ StartIoThreadAsyncCallback));
342
+ uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
343
+ start_io_thread_async.data = this;
344
+ - // Ignore failure, SIGUSR1 won't work, but that should not block node start.
345
+ - StartDebugSignalHandler();
346
+
347
+ parent_env_->AddCleanupHook([](void* data) {
348
+ Environment* env = static_cast<Environment*>(data);
349
+ diff --git node/src/node.cc node/src/node.cc
350
+ index 1067dee74c..8b32a10d08 100644
351
+ --- node/src/node.cc
352
+ +++ node/src/node.cc
353
+ @@ -312,6 +312,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
354
+ return env->RunSnapshotDeserializeMain();
355
+ }
356
+
357
+ + StartExecution(env, "internal/bootstrap/pkg");
358
+ +
359
+ if (env->worker_context() != nullptr) {
360
+ return StartExecution(env, "internal/main/worker_thread");
361
+ }
362
+ @@ -503,14 +505,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
363
+ }
364
+
365
+ if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
366
+ -#if HAVE_INSPECTOR
367
+ - sigset_t sigmask;
368
+ - sigemptyset(&sigmask);
369
+ - sigaddset(&sigmask, SIGUSR1);
370
+ - const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
371
+ - CHECK_EQ(err, 0);
372
+ -#endif // HAVE_INSPECTOR
373
+ -
374
+ ResetSignalHandlers();
375
+ }
376
+
377
+ diff --git node/src/node_contextify.cc node/src/node_contextify.cc
378
+ index ed552ddd55..f757ac3b49 100644
379
+ --- node/src/node_contextify.cc
380
+ +++ node/src/node_contextify.cc
381
+ @@ -75,6 +75,7 @@ using v8::ScriptOrigin;
382
+ using v8::String;
383
+ using v8::Uint32;
384
+ using v8::UnboundScript;
385
+ +using v8::V8;
386
+ using v8::Value;
387
+ using v8::WeakCallbackInfo;
388
+ using v8::WeakCallbackType;
389
+ @@ -771,11 +772,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
390
+ Local<ArrayBufferView> cached_data_buf;
391
+ bool produce_cached_data = false;
392
+ Local<Context> parsing_context = context;
393
+ + bool sourceless = false;
394
+
395
+ if (argc > 2) {
396
+ // new ContextifyScript(code, filename, lineOffset, columnOffset,
397
+ // cachedData, produceCachedData, parsingContext)
398
+ - CHECK_EQ(argc, 7);
399
+ + CHECK_EQ(argc, 8);
400
+ CHECK(args[2]->IsNumber());
401
+ line_offset = args[2].As<Int32>()->Value();
402
+ CHECK(args[3]->IsNumber());
403
+ @@ -794,6 +796,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
404
+ CHECK_NOT_NULL(sandbox);
405
+ parsing_context = sandbox->context();
406
+ }
407
+ + sourceless = args[7]->IsTrue();
408
+ }
409
+
410
+ ContextifyScript* contextify_script =
411
+ @@ -844,6 +847,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
412
+ ShouldNotAbortOnUncaughtScope no_abort_scope(env);
413
+ Context::Scope scope(parsing_context);
414
+
415
+ + if (sourceless && produce_cached_data) {
416
+ + V8::EnableCompilationForSourcelessUse();
417
+ + }
418
+ +
419
+ MaybeLocal<UnboundScript> maybe_v8_script =
420
+ ScriptCompiler::CompileUnboundScript(isolate, &source, compile_options);
421
+
422
+ @@ -857,6 +864,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
423
+ "ContextifyScript::New");
424
+ return;
425
+ }
426
+ +
427
+ + if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
428
+ + if (!source.GetCachedData()->rejected) {
429
+ + V8::FixSourcelessScript(env->isolate(), v8_script);
430
+ + }
431
+ + }
432
+ +
433
+ contextify_script->script_.Reset(isolate, v8_script);
434
+
435
+ std::unique_ptr<ScriptCompiler::CachedData> new_cached_data;
436
+ @@ -881,6 +895,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
437
+ .IsNothing())
438
+ return;
439
+
440
+ + if (sourceless && produce_cached_data) {
441
+ + V8::DisableCompilationForSourcelessUse();
442
+ + }
443
+ +
444
+ TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
445
+ }
446
+
447
+ diff --git node/src/node_main.cc node/src/node_main.cc
448
+ index d486bbc31c..eb806b1ce4 100644
449
+ --- node/src/node_main.cc
450
+ +++ node/src/node_main.cc
451
+ @@ -22,6 +22,8 @@
452
+ #include "node.h"
453
+ #include <cstdio>
454
+
455
+ +int reorder(int argc, char** argv);
456
+ +
457
+ #ifdef _WIN32
458
+ #include <windows.h>
459
+ #include <VersionHelpers.h>
460
+ @@ -84,12 +86,95 @@ int wmain(int argc, wchar_t* wargv[]) {
461
+ }
462
+ argv[argc] = nullptr;
463
+ // Now that conversion is done, we can finally start.
464
+ - return node::Start(argc, argv);
465
+ + return reorder(argc, argv);
466
+ }
467
+ #else
468
+ // UNIX
469
+
470
+ int main(int argc, char* argv[]) {
471
+ + return reorder(argc, argv);
472
+ +}
473
+ +#endif
474
+ +
475
+ +#include <string.h>
476
+ +
477
+ +int strlen2 (char* s) {
478
+ + int len = 0;
479
+ + while (*s) {
480
+ + len += 1;
481
+ + s += 1;
482
+ + }
483
+ + return len;
484
+ +}
485
+ +
486
+ +bool should_set_dummy() {
487
+ +#ifdef _WIN32
488
+ + #define MAX_ENV_LENGTH 32767
489
+ + wchar_t execpath_env[MAX_ENV_LENGTH];
490
+ + DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
491
+ + if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
492
+ + return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
493
+ +#else
494
+ + const char* execpath_env = getenv("PKG_EXECPATH");
495
+ + if (!execpath_env) return true;
496
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
497
+ +#endif
498
+ +}
499
+ +
500
+ +// for uv_setup_args
501
+ +int adjacent(int argc, char** argv) {
502
+ + size_t size = 0;
503
+ + for (int i = 0; i < argc; i++) {
504
+ + size += strlen(argv[i]) + 1;
505
+ + }
506
+ + char* args = new char[size];
507
+ + size_t pos = 0;
508
+ + for (int i = 0; i < argc; i++) {
509
+ + memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
510
+ + argv[i] = &args[pos];
511
+ + pos += strlen(argv[i]) + 1;
512
+ + }
513
+ return node::Start(argc, argv);
514
+ }
515
+ +
516
+ +volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
517
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
518
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
519
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
520
+ +
521
+ +#ifdef __clang__
522
+ +__attribute__((optnone))
523
+ +#elif defined(__GNUC__)
524
+ +__attribute__((optimize(0)))
525
+ #endif
526
+ +
527
+ +int load_baked(char** nargv) {
528
+ + int c = 1;
529
+ +
530
+ + char* bakery = (char*) BAKERY;
531
+ + while (true) {
532
+ + size_t width = strlen2(bakery);
533
+ + if (width == 0) break;
534
+ + nargv[c++] = bakery;
535
+ + bakery += width + 1;
536
+ + }
537
+ +
538
+ + return c;
539
+ +}
540
+ +
541
+ +int reorder(int argc, char** argv) {
542
+ + char** nargv = new char*[argc + 64];
543
+ +
544
+ + nargv[0] = argv[0];
545
+ + int c = load_baked(nargv);
546
+ +
547
+ + if (should_set_dummy()) {
548
+ + nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
549
+ + }
550
+ +
551
+ + for (int i = 1; i < argc; i++) {
552
+ + nargv[c++] = argv[i];
553
+ + }
554
+ +
555
+ + return adjacent(c, nargv);
556
+ +}
557
+ diff --git node/src/node_options.cc node/src/node_options.cc
558
+ index 6eabf78f1b..e9be1ed5ba 100644
559
+ --- node/src/node_options.cc
560
+ +++ node/src/node_options.cc
561
+ @@ -308,6 +308,7 @@ void Parse(
562
+ // TODO(addaleax): Make that unnecessary.
563
+
564
+ DebugOptionsParser::DebugOptionsParser() {
565
+ + return;
566
+ AddOption("--inspect-port",
567
+ "set host:port for inspector",
568
+ &DebugOptions::host_port,
569
+ diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
570
+ index db45e6fbdf..3e39f1fbdf 100644
571
+ --- node/tools/icu/icu-generic.gyp
572
+ +++ node/tools/icu/icu-generic.gyp
573
+ @@ -52,7 +52,7 @@
574
+ 'conditions': [
575
+ [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
576
+ 'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
577
+ - 'cflags_cc': [ '-frtti' ],
578
+ + 'cflags_cc': [ '-frtti', '-fno-lto' ],
579
+ 'cflags_cc!': [ '-fno-rtti' ],
580
+ }],
581
+ [ 'OS == "mac" or OS == "ios"', {