summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2019-06-18 11:36:26 -1000
committerSam Bingner <sam@bingner.com>2019-06-18 11:36:26 -1000
commit193f32e39e93ea855bda21c551362d9117160ba3 (patch)
tree1436c000819bbbfc7a3bb2a71c2d38c472fc48e8 /data
parent208a0713026db94975ed578a4ba59368453b2ad0 (diff)
Use a workaround for JIT on nodejs
Diffstat (limited to 'data')
-rw-r--r--data/nodejs/_metadata/version2
-rw-r--r--data/nodejs/jit.diff73
-rw-r--r--data/nodejs/make.sh2
-rw-r--r--data/nodejs/node.xml2
4 files changed, 76 insertions, 3 deletions
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 <cstdio>
++#include <sys/types.h>
++#include <sys/ptrace.h>
++#include <sys/wait.h>
++#include <unistd.h>
++#include <errno.h>
++#include <string.h>
+
+ #ifdef _WIN32
+ #include <windows.h>
+@@ -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 @@
<dict>
<key>platform-application</key>
<true/>
- <key>dynamic-codesigning</key>
+ <key>get-task-allow</key>
<true/>
</dict>
</plist>