@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,572 @@
1
+ diff --git node/common.gypi node/common.gypi
2
+ index cbf9c3810d..991792324e 100644
3
+ --- node/common.gypi
4
+ +++ node/common.gypi
5
+ @@ -179,7 +179,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 1d0a1741ce..342ade8435 100755
16
+ --- node/configure.py
17
+ +++ node/configure.py
18
+ @@ -1241,10 +1241,6 @@ 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
+ -
26
+ if options.node_snapshot_main is not None:
27
+ if options.shared:
28
+ # This should be possible to fix, but we will need to refactor the
29
+ diff --git node/deps/v8/include/v8.h node/deps/v8/include/v8.h
30
+ index eacdaae7f5..601fd94947 100644
31
+ --- node/deps/v8/include/v8.h
32
+ +++ node/deps/v8/include/v8.h
33
+ @@ -10092,6 +10092,10 @@ class V8_EXPORT V8 {
34
+ char** argv,
35
+ bool remove_flags);
36
+
37
+ + static void EnableCompilationForSourcelessUse();
38
+ + static void DisableCompilationForSourcelessUse();
39
+ + static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
40
+ +
41
+ /** Get the version string. */
42
+ static const char* GetVersion();
43
+
44
+ diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
45
+ index 1632be8f62..e222ed00d7 100644
46
+ --- node/deps/v8/src/api/api.cc
47
+ +++ node/deps/v8/src/api/api.cc
48
+ @@ -647,6 +647,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
49
+ HelpOptions(HelpOptions::kDontExit));
50
+ }
51
+
52
+ +bool save_lazy;
53
+ +bool save_predictable;
54
+ +
55
+ +void V8::EnableCompilationForSourcelessUse() {
56
+ + save_lazy = i::FLAG_lazy;
57
+ + i::FLAG_lazy = false;
58
+ + save_predictable = i::FLAG_predictable;
59
+ + i::FLAG_predictable = true;
60
+ +}
61
+ +
62
+ +void V8::DisableCompilationForSourcelessUse() {
63
+ + i::FLAG_lazy = save_lazy;
64
+ + i::FLAG_predictable = save_predictable;
65
+ +}
66
+ +
67
+ +void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
68
+ + auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
69
+ + auto function_info =
70
+ + i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
71
+ + i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
72
+ + script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
73
+ +}
74
+ +
75
+ RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
76
+
77
+ RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
78
+ diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
79
+ index 5c368c474e..4707995c12 100644
80
+ --- node/deps/v8/src/codegen/compiler.cc
81
+ +++ node/deps/v8/src/codegen/compiler.cc
82
+ @@ -2840,7 +2840,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
83
+ // First check per-isolate compilation cache.
84
+ maybe_result =
85
+ compilation_cache->LookupScript(source, script_details, language_mode);
86
+ - if (!maybe_result.is_null()) {
87
+ + if (!maybe_result.is_null() && source_length) {
88
+ compile_timer.set_hit_isolate_cache();
89
+ } else if (can_consume_code_cache) {
90
+ compile_timer.set_consuming_code_cache();
91
+ diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
92
+ index b2d086814f..52ba0bc9bc 100644
93
+ --- node/deps/v8/src/objects/js-function.cc
94
+ +++ node/deps/v8/src/objects/js-function.cc
95
+ @@ -953,6 +953,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
96
+ Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
97
+ function, isolate->factory()->class_positions_symbol());
98
+ if (maybe_class_positions->IsClassPositions()) {
99
+ + if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
100
+ + return isolate->factory()->NewStringFromAsciiChecked("class {}");
101
+ + }
102
+ ClassPositions class_positions =
103
+ ClassPositions::cast(*maybe_class_positions);
104
+ int start_position = class_positions.start();
105
+ diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h
106
+ index 583ca8dccf..83fc199993 100644
107
+ --- node/deps/v8/src/objects/shared-function-info-inl.h
108
+ +++ node/deps/v8/src/objects/shared-function-info-inl.h
109
+ @@ -631,6 +631,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
110
+ }
111
+ if (!data.IsBytecodeArray()) return false;
112
+
113
+ + Object script_obj = script();
114
+ + if (!script_obj.IsUndefined()) {
115
+ + Script script = Script::cast(script_obj);
116
+ + if (script.source().IsUndefined()) {
117
+ + return false;
118
+ + }
119
+ + }
120
+ +
121
+ if (IsStressFlushingEnabled(code_flush_mode)) return true;
122
+
123
+ BytecodeArray bytecode = BytecodeArray::cast(data);
124
+ diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
125
+ index 53f6cf045b..bc4ba3499f 100644
126
+ --- node/deps/v8/src/parsing/parsing.cc
127
+ +++ node/deps/v8/src/parsing/parsing.cc
128
+ @@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
129
+ Isolate* isolate, ReportStatisticsMode mode) {
130
+ DCHECK(info->flags().is_toplevel());
131
+ DCHECK_NULL(info->literal());
132
+ + if (String::cast(script->source()).IsUndefined(isolate)) return false;
133
+
134
+ VMState<PARSER> state(isolate);
135
+
136
+ @@ -76,6 +77,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
137
+
138
+ // Create a character stream for the parser.
139
+ Handle<Script> script(Script::cast(shared_info->script()), isolate);
140
+ + if (String::cast(script->source()).IsUndefined(isolate)) return false;
141
+ Handle<String> source(String::cast(script->source()), isolate);
142
+ isolate->counters()->total_parse_size()->Increment(source->length());
143
+ std::unique_ptr<Utf16CharacterStream> stream(
144
+ diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
145
+ index a8a39e0c64..f095af6c11 100644
146
+ --- node/deps/v8/src/snapshot/code-serializer.cc
147
+ +++ node/deps/v8/src/snapshot/code-serializer.cc
148
+ @@ -471,13 +471,9 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
149
+ uint32_t magic_number = GetMagicNumber();
150
+ if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
151
+ uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
152
+ - uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
153
+ - uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
154
+ uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
155
+ uint32_t c = GetHeaderValue(kChecksumOffset);
156
+ if (version_hash != Version::Hash()) return VERSION_MISMATCH;
157
+ - if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
158
+ - if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
159
+ uint32_t max_payload_length = this->size_ - kHeaderSize;
160
+ if (payload_length > max_payload_length) return LENGTH_MISMATCH;
161
+ if (Checksum(ChecksummedContent()) != c) return CHECKSUM_MISMATCH;
162
+ diff --git node/lib/child_process.js node/lib/child_process.js
163
+ index a4def6acce..113249f009 100644
164
+ --- node/lib/child_process.js
165
+ +++ node/lib/child_process.js
166
+ @@ -166,7 +166,7 @@ function fork(modulePath, args = [], options) {
167
+ options.execPath = options.execPath || process.execPath;
168
+ options.shell = false;
169
+
170
+ - return spawn(options.execPath, args, options);
171
+ + return module.exports.spawn(options.execPath, args, options);
172
+ }
173
+
174
+ function _forkChild(fd, serializationMode) {
175
+ diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
176
+ new file mode 100644
177
+ index 0000000000..fb2d47f52b
178
+ --- /dev/null
179
+ +++ node/lib/internal/bootstrap/pkg.js
180
+ @@ -0,0 +1,44 @@
181
+ +'use strict';
182
+ +
183
+ +const {
184
+ + prepareMainThreadExecution
185
+ +} = require('internal/bootstrap/pre_execution');
186
+ +
187
+ +prepareMainThreadExecution(true);
188
+ +
189
+ +(function () {
190
+ + var __require__ = require;
191
+ + var fs = __require__('fs');
192
+ + var vm = __require__('vm');
193
+ + function readPrelude (fd) {
194
+ + var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
195
+ + var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
196
+ + var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
197
+ + var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
198
+ + if (!PRELUDE_POSITION) {
199
+ + // no prelude - remove entrypoint from argv[1]
200
+ + process.argv.splice(1, 1);
201
+ + return { undoPatch: true };
202
+ + }
203
+ + var prelude = Buffer.alloc(PRELUDE_SIZE);
204
+ + var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
205
+ + if (read !== PRELUDE_SIZE) {
206
+ + console.error('Pkg: Error reading from file.');
207
+ + process.exit(1);
208
+ + }
209
+ + var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
210
+ + var fn = s.runInThisContext();
211
+ + return fn(process, __require__,
212
+ + console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
213
+ + }
214
+ + (function () {
215
+ + var fd = fs.openSync(process.execPath, 'r');
216
+ + var result = readPrelude(fd);
217
+ + if (result && result.undoPatch) {
218
+ + var bindingFs = process.binding('fs');
219
+ + fs.internalModuleStat = bindingFs.internalModuleStat;
220
+ + fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
221
+ + fs.closeSync(fd);
222
+ + }
223
+ + }());
224
+ +}());
225
+ diff --git node/lib/internal/bootstrap/pre_execution.js node/lib/internal/bootstrap/pre_execution.js
226
+ index a9f463c4d0..81dd9ce272 100644
227
+ --- node/lib/internal/bootstrap/pre_execution.js
228
+ +++ node/lib/internal/bootstrap/pre_execution.js
229
+ @@ -26,8 +26,13 @@ const { Buffer } = require('buffer');
230
+ const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
231
+ const assert = require('internal/assert');
232
+
233
+ +let _alreadyPrepared = false;
234
+ +
235
+ function prepareMainThreadExecution(expandArgv1 = false,
236
+ initialzeModules = true) {
237
+ + if (_alreadyPrepared === true) return;
238
+ + _alreadyPrepared = true;
239
+ +
240
+ refreshRuntimeOptions();
241
+
242
+ // TODO(joyeecheung): this is also necessary for workers when they deserialize
243
+ @@ -119,7 +124,8 @@ function patchProcessObject(expandArgv1) {
244
+ process.argv[0] = process.execPath;
245
+
246
+ if (expandArgv1 && process.argv[1] &&
247
+ - !StringPrototypeStartsWith(process.argv[1], '-')) {
248
+ + !StringPrototypeStartsWith(process.argv[1], '-') &&
249
+ + process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
250
+ // Expand process.argv[1] into a full path.
251
+ const path = require('path');
252
+ try {
253
+ diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
254
+ index 614ee758d2..a830dfa33d 100644
255
+ --- node/lib/internal/modules/cjs/loader.js
256
+ +++ node/lib/internal/modules/cjs/loader.js
257
+ @@ -92,7 +92,7 @@ const fs = require('fs');
258
+ const internalFS = require('internal/fs/utils');
259
+ const path = require('path');
260
+ const { sep } = path;
261
+ -const { internalModuleStat } = internalBinding('fs');
262
+ +const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
263
+ const packageJsonReader = require('internal/modules/package_json_reader');
264
+ const { safeGetenv } = internalBinding('credentials');
265
+ const {
266
+ diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
267
+ index 09eb12bd15..2d2f196737 100644
268
+ --- node/lib/internal/modules/package_json_reader.js
269
+ +++ node/lib/internal/modules/package_json_reader.js
270
+ @@ -1,7 +1,7 @@
271
+ 'use strict';
272
+
273
+ const { SafeMap } = primordials;
274
+ -const { internalModuleReadJSON } = internalBinding('fs');
275
+ +const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
276
+ const { pathToFileURL } = require('url');
277
+ const { toNamespacedPath } = require('path');
278
+
279
+ diff --git node/lib/vm.js node/lib/vm.js
280
+ index 1bb199363a..18ad0f86f2 100644
281
+ --- node/lib/vm.js
282
+ +++ node/lib/vm.js
283
+ @@ -79,6 +79,7 @@ class Script extends ContextifyScript {
284
+ produceCachedData = false,
285
+ importModuleDynamically,
286
+ [kParsingContext]: parsingContext,
287
+ + sourceless = false,
288
+ } = options;
289
+
290
+ validateString(filename, 'options.filename');
291
+ @@ -103,7 +104,8 @@ class Script extends ContextifyScript {
292
+ columnOffset,
293
+ cachedData,
294
+ produceCachedData,
295
+ - parsingContext);
296
+ + parsingContext,
297
+ + sourceless);
298
+ } catch (e) {
299
+ throw e; /* node-do-not-add-exception-line */
300
+ }
301
+ diff --git node/node.gyp node/node.gyp
302
+ index 5a91d76f45..a3299211ab 100644
303
+ --- node/node.gyp
304
+ +++ node/node.gyp
305
+ @@ -113,6 +113,9 @@
306
+ },
307
+
308
+ 'conditions': [
309
+ + ['target_arch=="arm64"', {
310
+ + 'cflags': ['-msign-return-address=all'], # Pointer authentication.
311
+ + }],
312
+ ['OS=="aix"', {
313
+ 'ldflags': [
314
+ '-Wl,-bnoerrmsg',
315
+ diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
316
+ index 9ee779fb59..560f363ad1 100644
317
+ --- node/src/inspector_agent.cc
318
+ +++ node/src/inspector_agent.cc
319
+ @@ -693,8 +693,6 @@ bool Agent::Start(const std::string& path,
320
+ StartIoThreadAsyncCallback));
321
+ uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
322
+ start_io_thread_async.data = this;
323
+ - // Ignore failure, SIGUSR1 won't work, but that should not block node start.
324
+ - StartDebugSignalHandler();
325
+
326
+ parent_env_->AddCleanupHook([](void* data) {
327
+ Environment* env = static_cast<Environment*>(data);
328
+ diff --git node/src/node.cc node/src/node.cc
329
+ index 8555a771b7..ce2ac7df03 100644
330
+ --- node/src/node.cc
331
+ +++ node/src/node.cc
332
+ @@ -481,6 +481,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
333
+ return env->RunSnapshotDeserializeMain();
334
+ }
335
+
336
+ + StartExecution(env, "internal/bootstrap/pkg");
337
+ +
338
+ if (env->worker_context() != nullptr) {
339
+ return StartExecution(env, "internal/main/worker_thread");
340
+ }
341
+ @@ -603,13 +605,6 @@ static struct {
342
+
343
+ inline void PlatformInit() {
344
+ #ifdef __POSIX__
345
+ -#if HAVE_INSPECTOR
346
+ - sigset_t sigmask;
347
+ - sigemptyset(&sigmask);
348
+ - sigaddset(&sigmask, SIGUSR1);
349
+ - const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
350
+ -#endif // HAVE_INSPECTOR
351
+ -
352
+ // Make sure file descriptors 0-2 are valid before we start logging anything.
353
+ for (auto& s : stdio) {
354
+ const int fd = &s - stdio;
355
+ @@ -625,10 +620,6 @@ inline void PlatformInit() {
356
+ ABORT();
357
+ }
358
+
359
+ -#if HAVE_INSPECTOR
360
+ - CHECK_EQ(err, 0);
361
+ -#endif // HAVE_INSPECTOR
362
+ -
363
+ // TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
364
+ #ifndef NODE_SHARED_MODE
365
+ // Restore signal dispositions, the parent process may have changed them.
366
+ diff --git node/src/node_contextify.cc node/src/node_contextify.cc
367
+ index a02c211db8..23b150d1a3 100644
368
+ --- node/src/node_contextify.cc
369
+ +++ node/src/node_contextify.cc
370
+ @@ -74,6 +74,7 @@ using v8::ScriptOrModule;
371
+ using v8::String;
372
+ using v8::Uint32;
373
+ using v8::UnboundScript;
374
+ +using v8::V8;
375
+ using v8::Value;
376
+ using v8::WeakCallbackInfo;
377
+ using v8::WeakCallbackType;
378
+ @@ -715,11 +716,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
379
+ Local<ArrayBufferView> cached_data_buf;
380
+ bool produce_cached_data = false;
381
+ Local<Context> parsing_context = context;
382
+ + bool sourceless = false;
383
+
384
+ if (argc > 2) {
385
+ // new ContextifyScript(code, filename, lineOffset, columnOffset,
386
+ // cachedData, produceCachedData, parsingContext)
387
+ - CHECK_EQ(argc, 7);
388
+ + CHECK_EQ(argc, 8);
389
+ CHECK(args[2]->IsNumber());
390
+ line_offset = args[2].As<Int32>()->Value();
391
+ CHECK(args[3]->IsNumber());
392
+ @@ -738,6 +740,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
393
+ CHECK_NOT_NULL(sandbox);
394
+ parsing_context = sandbox->context();
395
+ }
396
+ + sourceless = args[7]->IsTrue();
397
+ }
398
+
399
+ ContextifyScript* contextify_script =
400
+ @@ -789,6 +792,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
401
+ ShouldNotAbortOnUncaughtScope no_abort_scope(env);
402
+ Context::Scope scope(parsing_context);
403
+
404
+ + if (sourceless && produce_cached_data) {
405
+ + V8::EnableCompilationForSourcelessUse();
406
+ + }
407
+ +
408
+ MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
409
+ isolate,
410
+ &source,
411
+ @@ -803,6 +810,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
412
+ "ContextifyScript::New");
413
+ return;
414
+ }
415
+ +
416
+ + if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
417
+ + if (!source.GetCachedData()->rejected) {
418
+ + V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
419
+ + }
420
+ + }
421
+ +
422
+ contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
423
+
424
+ Local<Context> env_context = env->context();
425
+ @@ -829,6 +843,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
426
+ env->cached_data_produced_string(),
427
+ Boolean::New(isolate, cached_data_produced)).Check();
428
+ }
429
+ +
430
+ + if (sourceless && produce_cached_data) {
431
+ + V8::DisableCompilationForSourcelessUse();
432
+ + }
433
+ +
434
+ TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
435
+ }
436
+
437
+ diff --git node/src/node_main.cc node/src/node_main.cc
438
+ index 6bac107593..a897e2b9be 100644
439
+ --- node/src/node_main.cc
440
+ +++ node/src/node_main.cc
441
+ @@ -22,6 +22,8 @@
442
+ #include "node.h"
443
+ #include <cstdio>
444
+
445
+ +int reorder(int argc, char** argv);
446
+ +
447
+ #ifdef _WIN32
448
+ #include <windows.h>
449
+ #include <VersionHelpers.h>
450
+ @@ -84,7 +86,7 @@ int wmain(int argc, wchar_t* wargv[]) {
451
+ }
452
+ argv[argc] = nullptr;
453
+ // Now that conversion is done, we can finally start.
454
+ - return node::Start(argc, argv);
455
+ + return reorder(argc, argv);
456
+ }
457
+ #else
458
+ // UNIX
459
+ @@ -124,6 +126,88 @@ int main(int argc, char* argv[]) {
460
+ // calls elsewhere in the program (e.g., any logging from V8.)
461
+ setvbuf(stdout, nullptr, _IONBF, 0);
462
+ setvbuf(stderr, nullptr, _IONBF, 0);
463
+ + return reorder(argc, argv);
464
+ +}
465
+ +#endif
466
+ +
467
+ +#include <string.h>
468
+ +
469
+ +int strlen2 (char* s) {
470
+ + int len = 0;
471
+ + while (*s) {
472
+ + len += 1;
473
+ + s += 1;
474
+ + }
475
+ + return len;
476
+ +}
477
+ +
478
+ +bool should_set_dummy() {
479
+ +#ifdef _WIN32
480
+ + #define MAX_ENV_LENGTH 32767
481
+ + char execpath_env[MAX_ENV_LENGTH];
482
+ + DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
483
+ + if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
484
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
485
+ +#else
486
+ + const char* execpath_env = getenv("PKG_EXECPATH");
487
+ + if (!execpath_env) return true;
488
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
489
+ +#endif
490
+ +}
491
+ +
492
+ +// for uv_setup_args
493
+ +int adjacent(int argc, char** argv) {
494
+ + size_t size = 0;
495
+ + for (int i = 0; i < argc; i++) {
496
+ + size += strlen(argv[i]) + 1;
497
+ + }
498
+ + char* args = new char[size];
499
+ + size_t pos = 0;
500
+ + for (int i = 0; i < argc; i++) {
501
+ + memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
502
+ + argv[i] = &args[pos];
503
+ + pos += strlen(argv[i]) + 1;
504
+ + }
505
+ return node::Start(argc, argv);
506
+ }
507
+ +
508
+ +volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
509
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
510
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
511
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
512
+ +
513
+ +#ifdef __clang__
514
+ +__attribute__((optnone))
515
+ +#elif defined(__GNUC__)
516
+ +__attribute__((optimize(0)))
517
+ #endif
518
+ +int load_baked(char** nargv) {
519
+ + int c = 1;
520
+ +
521
+ + char* bakery = (char*) BAKERY;
522
+ + while (true) {
523
+ + size_t width = strlen2(bakery);
524
+ + if (width == 0) break;
525
+ + nargv[c++] = bakery;
526
+ + bakery += width + 1;
527
+ + }
528
+ +
529
+ + return c;
530
+ +}
531
+ +
532
+ +int reorder(int argc, char** argv) {
533
+ + char** nargv = new char*[argc + 64];
534
+ +
535
+ + nargv[0] = argv[0];
536
+ + int c = load_baked(nargv);
537
+ +
538
+ + if (should_set_dummy()) {
539
+ + nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
540
+ + }
541
+ +
542
+ + for (int i = 1; i < argc; i++) {
543
+ + nargv[c++] = argv[i];
544
+ + }
545
+ +
546
+ + return adjacent(c, nargv);
547
+ +}
548
+ diff --git node/src/node_options.cc node/src/node_options.cc
549
+ index f83356b0a6..90db52130a 100644
550
+ --- node/src/node_options.cc
551
+ +++ node/src/node_options.cc
552
+ @@ -299,6 +299,7 @@ void Parse(
553
+ // TODO(addaleax): Make that unnecessary.
554
+
555
+ DebugOptionsParser::DebugOptionsParser() {
556
+ + return;
557
+ AddOption("--inspect-port",
558
+ "set host:port for inspector",
559
+ &DebugOptions::host_port,
560
+ diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
561
+ index 3e830aa097..18ee19a2af 100644
562
+ --- node/tools/icu/icu-generic.gyp
563
+ +++ node/tools/icu/icu-generic.gyp
564
+ @@ -52,7 +52,7 @@
565
+ 'conditions': [
566
+ [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
567
+ 'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
568
+ - 'cflags_cc': [ '-frtti' ],
569
+ + 'cflags_cc': [ '-frtti', '-fno-lto' ],
570
+ 'cflags_cc!': [ '-fno-rtti' ],
571
+ }],
572
+ [ 'OS == "mac" or OS == "ios"', {