From b0abdb6b120c7da0d7c2b9772264c047d46e34e5 Mon Sep 17 00:00:00 2001 From: MCApollo <34170230+MCApollo@users.noreply.github.com> Date: Tue, 28 May 2019 22:04:11 +0000 Subject: Release candidate 2 --- data/node/README | 30 +++++++- data/node/init-options.diff | 143 ---------------------------------- data/node/install.diff | 26 ------- data/node/install.diff.disabled | 26 +++++++ data/node/jitless.diff | 165 ++++++++++++++++++++++++++++++++++++++++ data/node/make.sh | 7 +- 6 files changed, 223 insertions(+), 174 deletions(-) delete mode 100644 data/node/init-options.diff delete mode 100644 data/node/install.diff create mode 100644 data/node/install.diff.disabled create mode 100644 data/node/jitless.diff diff --git a/data/node/README b/data/node/README index 7d5c4c249..38aae846f 100644 --- a/data/node/README +++ b/data/node/README @@ -1,8 +1,32 @@ -In the case of linux, Clang 8 is required for the host. +MCApollo's Notes. + +In the case of linux, Clang 8 is required due to v8. + TODO (if bored): fix the usage of libs for target on host toolchain. -I've disable the need for it now. +I've disable/fixed the other issue for now (mksnapshot/want_seperate_toolchain). + +TODO: Fix the Makefile/install.py for a smoother install. TODO: Set all values uv cannot detect, like -os.cpus, os.hwfreq +os.cpus, os.hwfreq, the sysctl values are missing. + +TODO: Figure a less hacky way to get jitless working, +It doesn't work as v8 claims it should work or I'm doing something wrong. +Cleaner patches next time ^ + SIGCHLD will stop node. + +-> Setting CS_DEBUGGED in unc0ver doesn't work as intented? + +Shoutouts: +-> Coolstar/PPSSP maintainers, since I borrowed PPSSP's code to set CS_DEBUGGED. +-> Shawn Presser's version of node for iOS + He didn't try for jit it seems, Xcode just sets CS_DEBUGGED + when running from Xcode and it works for him I guess. + https://github.com/shawwn/node/tree/ios-release?files=1 +-> Node chakracore/nodejs-mobile maintainers for gyp edits and + leading me to try v8 node. + +Callouts: +-> Screw Node's build system, that's all. Knock down one language, go to the next. diff --git a/data/node/init-options.diff b/data/node/init-options.diff deleted file mode 100644 index a3faf707a..000000000 --- a/data/node/init-options.diff +++ /dev/null @@ -1,143 +0,0 @@ -diff -Naur node-v12.3.1/src/codesign.h node-v12.3.1+iPhone/src/codesign.h ---- node-v12.3.1/src/codesign.h 1970-01-01 00:00:00.000000000 +0000 -+++ node-v12.3.1+iPhone/src/codesign.h 2019-05-27 17:45:00.845971558 +0000 -@@ -0,0 +1,65 @@ -+/* -+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. -+ * -+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ -+ * -+ * This file contains Original Code and/or Modifications of Original Code -+ * as defined in and that are subject to the Apple Public Source License -+ * Version 2.0 (the 'License'). You may not use this file except in -+ * compliance with the License. The rights granted to you under the License -+ * may not be used to create, or enable the creation or redistribution of, -+ * unlawful or unlicensed copies of an Apple operating system, or to -+ * circumvent, violate, or enable the circumvention or violation of, any -+ * terms of an Apple operating system software license agreement. -+ * -+ * Please obtain a copy of the License at -+ * http://www.opensource.apple.com/apsl/ and read it before using this file. -+ * -+ * The Original Code and all software distributed under the License are -+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER -+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, -+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. -+ * Please see the License for the specific language governing rights and -+ * limitations under the License. -+ * -+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ -+ */ -+ -+#ifndef _SYS_CODESIGN_H_ -+#define _SYS_CODESIGN_H_ -+ -+#include -+ -+/* code signing attributes of a process */ -+#define CS_VALID 0x0001 /* dynamically valid */ -+#define CS_HARD 0x0100 /* don't load invalid pages */ -+#define CS_KILL 0x0200 /* kill process if it becomes invalid */ -+#define CS_EXEC_SET_HARD 0x1000 /* set CS_HARD on any exec'ed process */ -+#define CS_EXEC_SET_KILL 0x2000 /* set CS_KILL on any exec'ed process */ -+#define CS_KILLED 0x10000 /* was killed by kernel for invalidity */ -+#define CS_RESTRICT 0x20000 /* tell dyld to treat restricted */ -+ -+/* csops operations */ -+#define CS_OPS_STATUS 0 /* return status */ -+#define CS_OPS_MARKINVALID 1 /* invalidate process */ -+#define CS_OPS_MARKHARD 2 /* set HARD flag */ -+#define CS_OPS_MARKKILL 3 /* set KILL flag (sticky) */ -+#define CS_OPS_PIDPATH 4 /* get executable's pathname */ -+#define CS_OPS_CDHASH 5 /* get code directory hash */ -+#define CS_OPS_PIDOFFSET 6 /* get offset of active Mach-o slice */ -+#define CS_OPS_ENTITLEMENTS_BLOB 7 /* get entitlements blob */ -+#define CS_OPS_MARKRESTRICT 8 /* set RESTRICT flag (sticky) */ -+ -+#ifndef KERNEL -+ -+__BEGIN_DECLS -+ -+/* code sign operations */ -+int csops(pid_t pid, unsigned int ops, void * useraddr, size_t usersize); -+ -+__END_DECLS -+ -+#endif /* ! KERNEL */ -+ -+#endif /* _SYS_CODESIGN_H_ */ -diff -Naur node-v12.3.1/src/node.cc node-v12.3.1+iPhone/src/node.cc ---- node-v12.3.1/src/node.cc 2019-05-22 12:21:54.000000000 +0000 -+++ node-v12.3.1+iPhone/src/node.cc 2019-05-27 20:45:57.228246250 +0000 -@@ -94,6 +94,19 @@ - #include // STDIN_FILENO, STDERR_FILENO - #endif - -+#if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE -+#ifdef __cplusplus -+extern "C" { -+#endif -+ #include "codesign.h" -+ #include -+#ifdef __cplusplus -+} -+#endif -+ #define CS_OPS_STATUS 0 -+ #define CS_DEBUGGED 0x10000000 -+#endif -+ - // ========== global C++ headers ========== - - #include -@@ -625,13 +638,6 @@ - per_process::cli_options->cmdline = *argv; - #endif // NODE_REPORT - --#if defined(NODE_V8_OPTIONS) -- // Should come before the call to V8::SetFlagsFromCommandLine() -- // so the user can disable a flag --foo at run-time by passing -- // --no_foo from the command line. -- V8::SetFlagsFromString(NODE_V8_OPTIONS, sizeof(NODE_V8_OPTIONS) - 1); --#endif -- - std::shared_ptr default_env_options = - per_process::cli_options->per_isolate->per_env; - { -@@ -891,6 +897,22 @@ - params.snapshot_blob = blob; - } - -+#if defined(NODE_V8_OPTIONS) -+ V8::SetFlagsFromString(NODE_V8_OPTIONS, sizeof(NODE_V8_OPTIONS) - 1); -+ #if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE -+ /* -+ Even with '--jitless' it appears that node only works under a debugger. -+ https://github.com/hrydgard/ppsspp/commit/53e254d352986dc1093c620c58075189fd714a65 -+ https://github.com/hrydgard/ppsspp/issues/11905#issuecomment-476871010 -+ */ -+ uint32_t flags; -+ csops(getpid(), CS_OPS_STATUS, &flags, 0); -+ if (!(flags & CS_DEBUGGED)) { -+ syscall(SYS_ptrace, 0, 0, 0, 0); -+ } -+ #endif -+#endif -+ - NodeMainInstance main_instance(¶ms, - uv_default_loop(), - per_process::v8_platform.Platform(), -diff -Naur node-v12.3.1/src/node_options.cc node-v12.3.1+iPhone/src/node_options.cc ---- node-v12.3.1/src/node_options.cc 2019-05-22 12:21:54.000000000 +0000 -+++ node-v12.3.1+iPhone/src/node_options.cc 2019-05-27 09:00:23.775576108 +0000 -@@ -499,6 +499,10 @@ - kAllowedInEnvironment); - AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment); - -+#if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE -+ AddOption("--jitless", "", V8Option{}, kAllowedInEnvironment); -+#endif -+ - #ifdef NODE_REPORT - AddOption("--report-uncaught-exception", - "generate diagnostic report on uncaught exceptions", diff --git a/data/node/install.diff b/data/node/install.diff deleted file mode 100644 index be725d702..000000000 --- a/data/node/install.diff +++ /dev/null @@ -1,26 +0,0 @@ -diff -ur node-v12.3.1/tools/install.py node-v12.3.1+iPhone/tools/install.py ---- node-v12.3.1/tools/install.py 2019-05-22 12:21:55.000000000 +0000 -+++ node-v12.3.1+iPhone/tools/install.py 2019-05-28 00:22:25.356341629 +0000 -@@ -134,8 +134,8 @@ - output_file = 'lib' + output_file + '.' + variables.get('shlib_suffix') - # GYP will output to lib.target except on OS X, this is hardcoded - # in its source - see the _InstallableTargetInstallPath function. -- if sys.platform != 'darwin': -- output_prefix += 'lib.target/' -+# if sys.platform != 'darwin': -+# output_prefix += 'lib.target/' - - if 'false' == variables.get('node_shared'): - action([output_prefix + output_file], 'bin/' + output_file) -@@ -151,10 +151,7 @@ - action(['deps/v8/tools/gdbinit'], 'share/doc/node/') - action(['deps/v8/tools/lldb_commands.py'], 'share/doc/node/') - -- if 'freebsd' in sys.platform or 'openbsd' in sys.platform: -- action(['doc/node.1'], 'man/man1/') -- else: -- action(['doc/node.1'], 'share/man/man1/') -+ action(['doc/node.1'], 'share/man/man1/') - - if 'true' == variables.get('node_install_npm'): npm_files(action) - diff --git a/data/node/install.diff.disabled b/data/node/install.diff.disabled new file mode 100644 index 000000000..be725d702 --- /dev/null +++ b/data/node/install.diff.disabled @@ -0,0 +1,26 @@ +diff -ur node-v12.3.1/tools/install.py node-v12.3.1+iPhone/tools/install.py +--- node-v12.3.1/tools/install.py 2019-05-22 12:21:55.000000000 +0000 ++++ node-v12.3.1+iPhone/tools/install.py 2019-05-28 00:22:25.356341629 +0000 +@@ -134,8 +134,8 @@ + output_file = 'lib' + output_file + '.' + variables.get('shlib_suffix') + # GYP will output to lib.target except on OS X, this is hardcoded + # in its source - see the _InstallableTargetInstallPath function. +- if sys.platform != 'darwin': +- output_prefix += 'lib.target/' ++# if sys.platform != 'darwin': ++# output_prefix += 'lib.target/' + + if 'false' == variables.get('node_shared'): + action([output_prefix + output_file], 'bin/' + output_file) +@@ -151,10 +151,7 @@ + action(['deps/v8/tools/gdbinit'], 'share/doc/node/') + action(['deps/v8/tools/lldb_commands.py'], 'share/doc/node/') + +- if 'freebsd' in sys.platform or 'openbsd' in sys.platform: +- action(['doc/node.1'], 'man/man1/') +- else: +- action(['doc/node.1'], 'share/man/man1/') ++ action(['doc/node.1'], 'share/man/man1/') + + if 'true' == variables.get('node_install_npm'): npm_files(action) + diff --git a/data/node/jitless.diff b/data/node/jitless.diff new file mode 100644 index 000000000..f5cb3f95b --- /dev/null +++ b/data/node/jitless.diff @@ -0,0 +1,165 @@ +diff -Naur node-v12.3.1/deps/uv/src/unix/process.c node-v12.3.1+iPhone/deps/uv/src/unix/process.c +--- node-v12.3.1/deps/uv/src/unix/process.c 2019-05-22 12:21:52.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/uv/src/unix/process.c 2019-05-28 22:01:59.417155270 +0000 +@@ -267,7 +267,8 @@ + } + + +-#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)) ++#if !(defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_IPHONE)) ++// Disabled on iOS until MC fixes jitless, the syscall ruins spawning children. + /* execvp is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED, so must be + * avoided. Since this isn't called on those targets, the function + * doesn't even need to be defined for them. +@@ -411,7 +412,7 @@ + int uv_spawn(uv_loop_t* loop, + uv_process_t* process, + const uv_process_options_t* options) { +-#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) ++#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_IPHONE) + /* fork is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED. */ + return UV_ENOSYS; + #else +diff -Naur node-v12.3.1/src/codesign.h node-v12.3.1+iPhone/src/codesign.h +--- node-v12.3.1/src/codesign.h 1970-01-01 00:00:00.000000000 +0000 ++++ node-v12.3.1+iPhone/src/codesign.h 2019-05-28 22:00:20.085095406 +0000 +@@ -0,0 +1,65 @@ ++/* ++ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. ++ * ++ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ ++ * ++ * This file contains Original Code and/or Modifications of Original Code ++ * as defined in and that are subject to the Apple Public Source License ++ * Version 2.0 (the 'License'). You may not use this file except in ++ * compliance with the License. The rights granted to you under the License ++ * may not be used to create, or enable the creation or redistribution of, ++ * unlawful or unlicensed copies of an Apple operating system, or to ++ * circumvent, violate, or enable the circumvention or violation of, any ++ * terms of an Apple operating system software license agreement. ++ * ++ * Please obtain a copy of the License at ++ * http://www.opensource.apple.com/apsl/ and read it before using this file. ++ * ++ * The Original Code and all software distributed under the License are ++ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER ++ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ++ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. ++ * Please see the License for the specific language governing rights and ++ * limitations under the License. ++ * ++ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ ++ */ ++ ++#ifndef _SYS_CODESIGN_H_ ++#define _SYS_CODESIGN_H_ ++ ++#include ++ ++/* code signing attributes of a process */ ++#define CS_VALID 0x0001 /* dynamically valid */ ++#define CS_HARD 0x0100 /* don't load invalid pages */ ++#define CS_KILL 0x0200 /* kill process if it becomes invalid */ ++#define CS_EXEC_SET_HARD 0x1000 /* set CS_HARD on any exec'ed process */ ++#define CS_EXEC_SET_KILL 0x2000 /* set CS_KILL on any exec'ed process */ ++#define CS_KILLED 0x10000 /* was killed by kernel for invalidity */ ++#define CS_RESTRICT 0x20000 /* tell dyld to treat restricted */ ++ ++/* csops operations */ ++#define CS_OPS_STATUS 0 /* return status */ ++#define CS_OPS_MARKINVALID 1 /* invalidate process */ ++#define CS_OPS_MARKHARD 2 /* set HARD flag */ ++#define CS_OPS_MARKKILL 3 /* set KILL flag (sticky) */ ++#define CS_OPS_PIDPATH 4 /* get executable's pathname */ ++#define CS_OPS_CDHASH 5 /* get code directory hash */ ++#define CS_OPS_PIDOFFSET 6 /* get offset of active Mach-o slice */ ++#define CS_OPS_ENTITLEMENTS_BLOB 7 /* get entitlements blob */ ++#define CS_OPS_MARKRESTRICT 8 /* set RESTRICT flag (sticky) */ ++ ++#ifndef KERNEL ++ ++__BEGIN_DECLS ++ ++/* code sign operations */ ++int csops(pid_t pid, unsigned int ops, void * useraddr, size_t usersize); ++ ++__END_DECLS ++ ++#endif /* ! KERNEL */ ++ ++#endif /* _SYS_CODESIGN_H_ */ +diff -Naur node-v12.3.1/src/node.cc node-v12.3.1+iPhone/src/node.cc +--- node-v12.3.1/src/node.cc 2019-05-22 12:21:54.000000000 +0000 ++++ node-v12.3.1+iPhone/src/node.cc 2019-05-28 22:00:20.085095406 +0000 +@@ -94,6 +94,19 @@ + #include // STDIN_FILENO, STDERR_FILENO + #endif + ++#if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE ++#ifdef __cplusplus ++extern "C" { ++#endif ++ #include "codesign.h" ++ #include ++#ifdef __cplusplus ++} ++#endif ++ #define CS_OPS_STATUS 0 ++ #define CS_DEBUGGED 0x10000000 ++#endif ++ + // ========== global C++ headers ========== + + #include +@@ -625,13 +638,6 @@ + per_process::cli_options->cmdline = *argv; + #endif // NODE_REPORT + +-#if defined(NODE_V8_OPTIONS) +- // Should come before the call to V8::SetFlagsFromCommandLine() +- // so the user can disable a flag --foo at run-time by passing +- // --no_foo from the command line. +- V8::SetFlagsFromString(NODE_V8_OPTIONS, sizeof(NODE_V8_OPTIONS) - 1); +-#endif +- + std::shared_ptr default_env_options = + per_process::cli_options->per_isolate->per_env; + { +@@ -891,6 +897,22 @@ + params.snapshot_blob = blob; + } + ++#if defined(NODE_V8_OPTIONS) ++ V8::SetFlagsFromString(NODE_V8_OPTIONS, sizeof(NODE_V8_OPTIONS) - 1); ++ #if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE ++ /* ++ Even with '--jitless' it appears that node only works under a debugger. ++ https://github.com/hrydgard/ppsspp/commit/53e254d352986dc1093c620c58075189fd714a65 ++ https://github.com/hrydgard/ppsspp/issues/11905#issuecomment-476871010 ++ */ ++ uint32_t flags; ++ csops(getpid(), CS_OPS_STATUS, &flags, 0); ++ if (!(flags & CS_DEBUGGED)) { ++ syscall(SYS_ptrace, 0, 0, 0, 0); ++ } ++ #endif ++#endif ++ + NodeMainInstance main_instance(¶ms, + uv_default_loop(), + per_process::v8_platform.Platform(), +diff -Naur node-v12.3.1/src/node_options.cc node-v12.3.1+iPhone/src/node_options.cc +--- node-v12.3.1/src/node_options.cc 2019-05-22 12:21:54.000000000 +0000 ++++ node-v12.3.1+iPhone/src/node_options.cc 2019-05-28 22:00:20.085095406 +0000 +@@ -499,6 +499,10 @@ + kAllowedInEnvironment); + AddOption("--stack-trace-limit", "", V8Option{}, kAllowedInEnvironment); + ++#if TARGET_OS_IPHONE || V8_TARGET_OS_IPHONE ++ AddOption("--jitless", "", V8Option{}, kAllowedInEnvironment); ++#endif ++ + #ifdef NODE_REPORT + AddOption("--report-uncaught-exception", + "generate diagnostic report on uncaught exceptions", diff --git a/data/node/make.sh b/data/node/make.sh index a7c375eaf..df1caa5ed 100644 --- a/data/node/make.sh +++ b/data/node/make.sh @@ -1,7 +1,10 @@ pkg:setup -export CC="${PKG_TARG}-gcc" -export CXX="${PKG_TARG}-g++" +export _DEFINES="-DTARGET_OS_WATCH" +# Disable fork(), exec() until jitless gets working correctly. + +export CC="${PKG_TARG}-gcc ${_DEFINES}" +export CXX="${PKG_TARG}-g++ ${_DEFINES}" export LD="${PKG_TARG}-ld" export AR="${PKG_TARG}-ar" export RANLIB="${PKG_TARG}-ranlib" -- cgit v1.2.3