From 193f32e39e93ea855bda21c551362d9117160ba3 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Tue, 18 Jun 2019 11:36:26 -1000 Subject: Use a workaround for JIT on nodejs --- data/nodejs/_metadata/version | 2 +- data/nodejs/jit.diff | 73 +++++++++++++++++++++++++++++++++++++++++++ data/nodejs/make.sh | 2 +- data/nodejs/node.xml | 2 +- 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 data/nodejs/jit.diff (limited to 'data') diff --git a/data/nodejs/_metadata/version b/data/nodejs/_metadata/version index 18dca7ffd..d0879ad95 100644 --- a/data/nodejs/_metadata/version +++ b/data/nodejs/_metadata/version @@ -1 +1 @@ -12.3.1~a1 +12.3.1~b1 diff --git a/data/nodejs/jit.diff b/data/nodejs/jit.diff new file mode 100644 index 000000000..c64201e39 --- /dev/null +++ b/data/nodejs/jit.diff @@ -0,0 +1,73 @@ +diff -ur node-v12.3.1/src/node_main.cc node-v12.3.1+JIT/src/node_main.cc +--- node-v12.3.1/src/node_main.cc 2019-05-22 02:21:54.000000000 -1000 ++++ node-v12.3.1+JIT/src/node_main.cc 2019-06-18 11:15:25.000000000 -1000 +@@ -21,6 +21,12 @@ + + #include "node.h" + #include ++#include ++#include ++#include ++#include ++#include ++#include + + #ifdef _WIN32 + #include +@@ -93,6 +99,46 @@ + } // namespace per_process + } // namespace node + ++#define CS_OPS_STATUS 0 ++#define CS_DEBUGGED 0x10000000 ++extern "C" int csops(pid_t pid, unsigned int ops, void * useraddr, size_t usersize); ++bool get_debugged() { ++ int flags; ++ int rv = csops(getpid(), CS_OPS_STATUS, &flags, sizeof(flags)); ++ if (rv==0 && flags&CS_DEBUGGED) return true; ++ ++ pid_t pid = fork(); ++ if (pid) { ++ int st; ++ waitpid(pid, &st, 0); ++ } else if (pid == 0) { ++ pid_t ppid = getppid(); ++ int rv = ptrace(PT_ATTACHEXC, ppid, 0, 0); ++ if (rv) { ++ perror("Unable to attach to process"); ++ exit(1); ++ } ++ for (int i=0; i<100; i++) { ++ usleep(1000); ++ errno = 0; ++ rv = ptrace(PT_DETACH, ppid, 0, 0); ++ if (rv==0) break; ++ } ++ if (rv) { ++ perror("Unable to detach from process"); ++ exit(1); ++ } ++ exit(0); ++ } else { ++ perror("Unable to fork"); ++ } ++ ++ rv = csops(getpid(), CS_OPS_STATUS, &flags, sizeof(flags)); ++ if (rv==0 && flags&CS_DEBUGGED) return true; ++ ++ return false; ++} ++ + int main(int argc, char* argv[]) { + #if defined(__POSIX__) && defined(NODE_SHARED_MODE) + // In node::PlatformInit(), we squash all signal handlers for non-shared lib +@@ -119,6 +165,9 @@ + } + } + #endif ++ if (!get_debugged()) { ++ fprintf(stderr, "Unable to obtain CS_DEBUGGED - I will probably die now.\n"); ++ } + // Disable stdio buffering, it interacts poorly with printf() + // calls elsewhere in the program (e.g., any logging from V8.) + setvbuf(stdout, nullptr, _IONBF, 0); diff --git a/data/nodejs/make.sh b/data/nodejs/make.sh index a8b85aa45..c3f4c737b 100644 --- a/data/nodejs/make.sh +++ b/data/nodejs/make.sh @@ -29,7 +29,7 @@ PKG_CONFIG="$(realpath "${PKG_BASE}/util/pkg-config.sh")" \ # Don't use pkg:make, CC_host gets overwritten SDKROOT="" \ -make BUILDTYPE=Release DESTCPU=arm64 install DESTDIR="${PKG_DEST}" -j32 +make BUILDTYPE=Release DESTCPU=arm64 install DESTDIR="${PKG_DEST}" -j16 pkg: mkdir -p /usr/bin pkg: cp out/Release/node /usr/bin/ ldid -S"${PKG_DATA}/node.xml" "${PKG_DEST}/usr/bin/node" diff --git a/data/nodejs/node.xml b/data/nodejs/node.xml index 00f59d885..3ce49679c 100644 --- a/data/nodejs/node.xml +++ b/data/nodejs/node.xml @@ -3,7 +3,7 @@ platform-application - dynamic-codesigning + get-task-allow -- cgit v1.2.3