From f501927d7eaf972d525a608fde14570ca06d5279 Mon Sep 17 00:00:00 2001 From: MCApollo <34170230+MCApollo@users.noreply.github.com> Date: Tue, 21 May 2019 15:25:27 +0000 Subject: Add node.js --- data/node/README | 32 ++++ data/node/_metadata/cares.dep | 1 + data/node/_metadata/description | 1 + data/node/_metadata/in.1443.00 | 0 data/node/_metadata/libssl1.1.dep | 1 + data/node/_metadata/maintainer | 1 + data/node/_metadata/name | 1 + data/node/_metadata/priority | 1 + data/node/_metadata/role | 1 + data/node/_metadata/section | 1 + data/node/_metadata/tags | 1 + data/node/_metadata/version | 1 + data/node/configure-ios.diff | 363 ++++++++++++++++++++++++++++++++++++++ data/node/gyp.diff | 76 ++++++++ data/node/install.diff.disabled | 26 +++ data/node/jitless.diff | 165 +++++++++++++++++ data/node/make.sh | 36 ++++ data/node/node-v12.3.1.tar.gz | Bin 0 -> 49112048 bytes data/node/v8.diff | 167 ++++++++++++++++++ data/node/xcode_emulation.diff | 77 ++++++++ 20 files changed, 952 insertions(+) create mode 100644 data/node/README create mode 120000 data/node/_metadata/cares.dep create mode 100644 data/node/_metadata/description create mode 100644 data/node/_metadata/in.1443.00 create mode 120000 data/node/_metadata/libssl1.1.dep create mode 120000 data/node/_metadata/maintainer create mode 100644 data/node/_metadata/name create mode 100644 data/node/_metadata/priority create mode 100644 data/node/_metadata/role create mode 100644 data/node/_metadata/section create mode 100644 data/node/_metadata/tags create mode 100644 data/node/_metadata/version create mode 100644 data/node/configure-ios.diff create mode 100644 data/node/gyp.diff create mode 100644 data/node/install.diff.disabled create mode 100644 data/node/jitless.diff create mode 100644 data/node/make.sh create mode 100644 data/node/node-v12.3.1.tar.gz create mode 100644 data/node/v8.diff create mode 100644 data/node/xcode_emulation.diff diff --git a/data/node/README b/data/node/README new file mode 100644 index 000000000..38aae846f --- /dev/null +++ b/data/node/README @@ -0,0 +1,32 @@ +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/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, 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/_metadata/cares.dep b/data/node/_metadata/cares.dep new file mode 120000 index 000000000..4e3a4f848 --- /dev/null +++ b/data/node/_metadata/cares.dep @@ -0,0 +1 @@ +../../cares \ No newline at end of file diff --git a/data/node/_metadata/description b/data/node/_metadata/description new file mode 100644 index 000000000..f1d8dad9d --- /dev/null +++ b/data/node/_metadata/description @@ -0,0 +1 @@ +Platform built on V8 to build network applications diff --git a/data/node/_metadata/in.1443.00 b/data/node/_metadata/in.1443.00 new file mode 100644 index 000000000..e69de29bb diff --git a/data/node/_metadata/libssl1.1.dep b/data/node/_metadata/libssl1.1.dep new file mode 120000 index 000000000..71bfa9edd --- /dev/null +++ b/data/node/_metadata/libssl1.1.dep @@ -0,0 +1 @@ +../../libssl1.1 \ No newline at end of file diff --git a/data/node/_metadata/maintainer b/data/node/_metadata/maintainer new file mode 120000 index 000000000..0c538aadb --- /dev/null +++ b/data/node/_metadata/maintainer @@ -0,0 +1 @@ +../../../people/mac \ No newline at end of file diff --git a/data/node/_metadata/name b/data/node/_metadata/name new file mode 100644 index 000000000..2b6218596 --- /dev/null +++ b/data/node/_metadata/name @@ -0,0 +1 @@ +Node diff --git a/data/node/_metadata/priority b/data/node/_metadata/priority new file mode 100644 index 000000000..134d9bc32 --- /dev/null +++ b/data/node/_metadata/priority @@ -0,0 +1 @@ +optional diff --git a/data/node/_metadata/role b/data/node/_metadata/role new file mode 100644 index 000000000..52b4d7301 --- /dev/null +++ b/data/node/_metadata/role @@ -0,0 +1 @@ +hacker diff --git a/data/node/_metadata/section b/data/node/_metadata/section new file mode 100644 index 000000000..ddc7f1fd8 --- /dev/null +++ b/data/node/_metadata/section @@ -0,0 +1 @@ +Scripting diff --git a/data/node/_metadata/tags b/data/node/_metadata/tags new file mode 100644 index 000000000..ad5d50831 --- /dev/null +++ b/data/node/_metadata/tags @@ -0,0 +1 @@ +purpose::console diff --git a/data/node/_metadata/version b/data/node/_metadata/version new file mode 100644 index 000000000..9c028e25d --- /dev/null +++ b/data/node/_metadata/version @@ -0,0 +1 @@ +12.3.1 diff --git a/data/node/configure-ios.diff b/data/node/configure-ios.diff new file mode 100644 index 000000000..053234802 --- /dev/null +++ b/data/node/configure-ios.diff @@ -0,0 +1,363 @@ +diff -ur node-v12.3.1/common.gypi node-v12.3.1+iPhone/common.gypi +--- node-v12.3.1/common.gypi 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/common.gypi 2019-05-25 00:16:01.809813352 +0000 +@@ -95,7 +95,7 @@ + 'os_posix': 1, + 'v8_postmortem_support%': 1, + }], +- ['OS == "mac"', { ++ ['OS == "mac" or OS=="ios"', { + 'obj_dir%': '<(PRODUCT_DIR)/obj.target', + 'v8_base': '<(PRODUCT_DIR)/libv8_base.a', + }], +@@ -104,7 +104,7 @@ + }, { + 'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)', + }], +- ['OS=="mac"', { ++ ['OS=="mac" or OS=="ios"', { + 'clang%': 1, + }], + ], +@@ -172,7 +172,7 @@ + # pull in V8's postmortem metadata + 'ldflags': [ '-Wl,-z,allextract' ] + }], +- ['OS!="mac" and OS!="win"', { ++ ['OS!="mac" and OS!="ios" and OS!="win"', { + 'cflags': [ '-fno-omit-frame-pointer' ], + }], + ['OS=="linux"', { +@@ -293,7 +293,7 @@ + [ 'target_arch=="arm64"', { + 'msvs_configuration_platform': 'arm64', + }], +- ['asan == 1 and OS != "mac"', { ++ ['asan == 1 and (OS != "mac" or OS != "ios")', { + 'cflags+': [ + '-fno-omit-frame-pointer', + '-fsanitize=address', +@@ -302,7 +302,7 @@ + 'cflags!': [ '-fomit-frame-pointer' ], + 'ldflags': [ '-fsanitize=address' ], + }], +- ['asan == 1 and OS == "mac"', { ++ ['asan == 1 and (OS == "mac" or OS == "ios")', { + 'xcode_settings': { + 'OTHER_CFLAGS+': [ + '-fno-omit-frame-pointer', +@@ -425,6 +425,21 @@ + }], + ], + }], ++ ['OS=="ios"', { ++ 'defines': [ ++ '__IPHONEOS__', ++ 'TARGET_OS_IPHONE', ++ 'V8_TARGET_OS_IPHONE', ++ '_DARWIN_USE_64_BIT_INODE', ++ '__AARCH64EL__', ++ '_M_ARM64', ++ ], ++ 'cflags': [ ++ '-fno-exceptions', ++ '-fno-rtti', ++ '-fno-strict-aliasing' ++ ], ++ }], + ['OS=="mac"', { + 'defines': ['_DARWIN_USE_64_BIT_INODE=1'], + 'xcode_settings': { +@@ -436,7 +451,6 @@ + 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti + 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings + 'PREBINDING': 'NO', # No -Wl,-prebind +- 'MACOSX_DEPLOYMENT_TARGET': '10.10', # -mmacosx-version-min=10.10 + 'USE_HEADERMAP': 'NO', + 'OTHER_CFLAGS': [ + '-fno-strict-aliasing', +@@ -465,6 +479,9 @@ + ['target_arch=="x64"', { + 'xcode_settings': {'ARCHS': ['x86_64']}, + }], ++ [ 'target_arch=="arm64"', { ++ 'xcode_settings': {'ARCHS': ['arm64']}, ++ }], + ['clang==1', { + 'xcode_settings': { + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', +diff -ur node-v12.3.1/configure.py node-v12.3.1+iPhone/configure.py +--- node-v12.3.1/configure.py 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/configure.py 2019-05-25 00:16:01.809813352 +0000 +@@ -44,7 +44,7 @@ + parser = optparse.OptionParser() + + valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux', +- 'android', 'aix', 'cloudabi') ++ 'ios', 'android', 'aix', 'cloudabi') + valid_arch = ('arm', 'arm64', 'ia32', 'ppc', + 'ppc64', 'x32','x64', 'x86', 'x86_64', 's390', 's390x') + valid_arm_float_abi = ('soft', 'softfp', 'hard') +@@ -908,6 +908,8 @@ + def configure_node(o): + if options.dest_os == 'android': + o['variables']['OS'] = 'android' ++ if options.dest_os == 'ios': ++ o['variables']['OS'] = 'ios' + o['variables']['node_prefix'] = options.prefix + o['variables']['node_install_npm'] = b(not options.without_npm) + o['variables']['node_report'] = b(not options.without_report) +@@ -1069,12 +1071,7 @@ + o['variables']['node_shared'] = b(options.shared) + node_module_version = getmoduleversion.get_version() + +- if sys.platform == 'darwin': +- shlib_suffix = '%s.dylib' +- elif sys.platform.startswith('aix'): +- shlib_suffix = '%s.a' +- else: +- shlib_suffix = 'so.%s' ++ shlib_suffix = '%s.dylib' + + shlib_suffix %= node_module_version + o['variables']['node_module_version'] = int(node_module_version) +diff -ur node-v12.3.1/deps/brotli/brotli.gyp node-v12.3.1+iPhone/deps/brotli/brotli.gyp +--- node-v12.3.1/deps/brotli/brotli.gyp 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/brotli/brotli.gyp 2019-05-25 00:16:01.809813352 +0000 +@@ -15,7 +15,7 @@ + 'OS_FREEBSD' + ] + }], +- ['OS=="mac"', { ++ ['OS=="mac" or OS=="ios"', { + 'defines': [ + 'OS_MACOSX' + ] +diff -ur node-v12.3.1/deps/cares/cares.gyp node-v12.3.1+iPhone/deps/cares/cares.gyp +--- node-v12.3.1/deps/cares/cares.gyp 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/cares/cares.gyp 2019-05-25 00:16:01.813813354 +0000 +@@ -145,7 +145,7 @@ + 'include_dirs': [ 'config/linux' ], + 'sources': [ 'config/linux/ares_config.h' ] + }], +- [ 'OS=="mac"', { ++ [ 'OS=="mac" or OS=="ios"', { + 'include_dirs': [ 'config/darwin' ], + 'sources': [ 'config/darwin/ares_config.h' ] + }], +diff -ur node-v12.3.1/deps/npm/node_modules/node-gyp/addon.gypi node-v12.3.1+iPhone/deps/npm/node_modules/node-gyp/addon.gypi +--- node-v12.3.1/deps/npm/node_modules/node-gyp/addon.gypi 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/npm/node_modules/node-gyp/addon.gypi 2019-05-25 00:16:01.813813354 +0000 +@@ -79,7 +79,7 @@ + ], + + 'conditions': [ +- [ 'OS=="mac"', { ++ [ 'OS=="mac" or OS=="ios"', { + 'defines': [ + '_DARWIN_USE_64_BIT_INODE=1' + ], +diff -ur node-v12.3.1/deps/npm/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp node-v12.3.1+iPhone/deps/npm/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp +--- node-v12.3.1/deps/npm/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp 2019-05-22 12:21:51.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/npm/node_modules/node-gyp/gyp/tools/emacs/testdata/media.gyp 2019-05-25 00:16:01.813813354 +0000 +@@ -545,12 +545,12 @@ + 'base/simd/scale_yuv_to_rgb_sse2_x64.asm', + ], + }], +- [ 'os_posix == 1 and OS != "mac" and OS != "android"', { ++ [ 'os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', { + 'cflags': [ + '-msse2', + ], + }], +- [ 'OS == "mac"', { ++ [ 'OS == "mac" or OS == "ios"', { + 'configurations': { + 'Debug': { + 'xcode_settings': { +@@ -572,7 +572,7 @@ + ], + }, + }], +- [ 'OS=="mac"', { ++ [ 'OS=="mac" or OS=="ios"', { + 'variables': { + 'yasm_flags': [ + '-DPREFIX', +@@ -582,7 +582,7 @@ + ], + }, + }], +- [ 'os_posix==1 and OS!="mac"', { ++ [ 'os_posix==1 and OS!="mac" and OS!="ios"', { + 'variables': { + 'conditions': [ + [ 'target_arch=="ia32"', { +@@ -710,7 +710,7 @@ + 'webm/webm_parser_unittest.cc', + ], + 'conditions': [ +- ['os_posix==1 and OS!="mac"', { ++ ['os_posix==1 and OS!="mac" and OS!="ios"', { + 'conditions': [ + ['linux_use_tcmalloc==1', { + 'dependencies': [ +@@ -930,7 +930,7 @@ + }, + ], + }], +- ['os_posix == 1 and OS != "mac" and OS != "android"', { ++ ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', { + 'targets': [ + { + 'target_name': 'player_x11', +@@ -1064,7 +1064,7 @@ + 'filters/pipeline_integration_test_base.cc', + ], + 'conditions': [ +- ['os_posix==1 and OS!="mac"', { ++ ['os_posix==1 and OS!="mac" and OS!="ios"', { + 'conditions': [ + ['linux_use_tcmalloc==1', { + 'dependencies': [ +diff -ur node-v12.3.1/deps/uv/common.gypi node-v12.3.1+iPhone/deps/uv/common.gypi +--- node-v12.3.1/deps/uv/common.gypi 2019-05-22 12:21:52.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/uv/common.gypi 2019-05-25 00:16:01.813813354 +0000 +@@ -168,6 +168,13 @@ + }], + ], + }], ++ ['OS=="ios"', { ++ 'cflags': [ ++ '-fno-exceptions', ++ '-fno-rtti', ++ '-fno-threadsafe-statics' ++ ], ++ }], + ['OS=="mac"', { + 'xcode_settings': { + 'ALWAYS_SEARCH_USER_PATHS': 'NO', +diff -ur node-v12.3.1/deps/uv/uv.gyp node-v12.3.1+iPhone/deps/uv/uv.gyp +--- node-v12.3.1/deps/uv/uv.gyp 2019-05-22 12:21:52.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/uv/uv.gyp 2019-05-25 00:16:01.813813354 +0000 +@@ -198,7 +198,7 @@ + }], + ], + }], +- ['uv_library=="shared_library" and OS!="mac" and OS!="zos"', { ++ ['uv_library=="shared_library" and OS!="mac" and OS!="ios" and OS!="zos"', { + # This will cause gyp to set soname + # Must correspond with UV_VERSION_MAJOR + # in include/uv/version.h +diff -ur node-v12.3.1/node.gyp node-v12.3.1+iPhone/node.gyp +--- node-v12.3.1/node.gyp 2019-05-22 12:21:54.000000000 +0000 ++++ node-v12.3.1+iPhone/node.gyp 2019-05-25 12:01:52.868864501 +0000 +@@ -351,9 +351,8 @@ + 'conditions': [ + ['OS!="aix"', { + 'ldflags': [ +- '-Wl,--whole-archive,<(obj_dir)/<(STATIC_LIB_PREFIX)' ++ '-Wl,-force_load,<(obj_dir)/<(STATIC_LIB_PREFIX)' + '<(node_core_target_name)<(STATIC_LIB_SUFFIX)', +- '-Wl,--no-whole-archive', + ], + }], + [ 'OS=="win"', { +@@ -414,7 +413,7 @@ + }, + }, + }], +- ['want_separate_host_toolset==0', { ++ ['want_separate_host_toolset==1', { + 'dependencies': [ + 'mkcodecache', + ], +@@ -760,7 +759,7 @@ + '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o' + ], + }], +- [ 'OS!="mac" and OS!="linux"', { ++ [ 'OS!="mac" and OS!="ios" and OS!="linux"', { + 'sources': [ + 'src/node_dtrace_ustack.cc', + 'src/node_dtrace_provider.cc', +@@ -939,7 +938,7 @@ + 'target_name': 'node_dtrace_provider', + 'type': 'none', + 'conditions': [ +- [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { ++ [ 'node_use_dtrace=="true" and OS!="mac" and OS!="ios" and OS!="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_provider_o', +@@ -974,7 +973,7 @@ + 'target_name': 'node_dtrace_ustack', + 'type': 'none', + 'conditions': [ +- [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', { ++ [ 'node_use_dtrace=="true" and OS!="mac" and OS!="ios" and OS!="linux"', { + 'actions': [ + { + 'action_name': 'node_dtrace_ustack_constants', +diff -ur node-v12.3.1/node.gypi node-v12.3.1+iPhone/node.gypi +--- node-v12.3.1/node.gypi 2019-05-22 12:21:54.000000000 +0000 ++++ node-v12.3.1+iPhone/node.gypi 2019-05-25 12:03:43.012932500 +0000 +@@ -143,9 +143,8 @@ + 'conditions': [ + ['OS!="aix" and node_shared=="false"', { + 'ldflags': [ +- '-Wl,--whole-archive,' ++ '-Wl,-force_load,' + '<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)', +- '-Wl,--no-whole-archive', + ], + }], + ], +@@ -184,9 +183,8 @@ + 'conditions': [ + ['OS!="aix" and node_shared=="false"', { + 'ldflags': [ +- '-Wl,--whole-archive,' ++ '-Wl,-force_load,' + '<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)', +- '-Wl,--no-whole-archive', + ], + }], + ], +@@ -202,7 +200,7 @@ + 'dependencies': [ 'deps/brotli/brotli.gyp:brotli' ], + }], + +- [ 'OS=="mac"', { ++ [ 'OS=="mac" or OS=="ios"', { + # linking Corefoundation is needed since certain OSX debugging tools + # like Instruments require it for some features + 'libraries': [ '-framework CoreFoundation' ], +diff -ur node-v12.3.1/tools/v8_gypfiles/d8.gyp node-v12.3.1+iPhone/tools/v8_gypfiles/d8.gyp +--- node-v12.3.1/tools/v8_gypfiles/d8.gyp 2019-05-22 12:21:55.000000000 +0000 ++++ node-v12.3.1+iPhone/tools/v8_gypfiles/d8.gyp 2019-05-25 00:16:01.817813355 +0000 +@@ -43,7 +43,7 @@ + 'd8_js2c#host', + ], + }], +- ['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \ ++ ['(OS=="linux" or OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="netbsd" \ + or OS=="openbsd" or OS=="solaris" or OS=="android" \ + or OS=="qnx" or OS=="aix")', { + 'sources': [ '../src/d8-posix.cc', ] +diff -ur node-v12.3.1/tools/v8_gypfiles/v8.gyp node-v12.3.1+iPhone/tools/v8_gypfiles/v8.gyp +--- node-v12.3.1/tools/v8_gypfiles/v8.gyp 2019-05-22 12:21:55.000000000 +0000 ++++ node-v12.3.1+iPhone/tools/v8_gypfiles/v8.gyp 2019-05-25 00:16:01.817813355 +0000 +@@ -128,6 +128,12 @@ + 'OTHER_LDFLAGS': ['-dynamiclib', '-all_load'] + }, + }], ++ ['OS=="ios"', { ++ 'ldflags': [ ++ '-dynamiclib', ++ '-all_load' ++ ], ++ }], + ['soname_version!=""', { + 'product_extension': 'so.<(soname_version)', + }], diff --git a/data/node/gyp.diff b/data/node/gyp.diff new file mode 100644 index 000000000..bf41b1113 --- /dev/null +++ b/data/node/gyp.diff @@ -0,0 +1,76 @@ +diff -ur node-v12.2.0/tools/gyp/pylib/gyp/generator/make.py node-v12.2.0+iPhone/tools/gyp/pylib/gyp/generator/make.py +--- node-v12.2.0/tools/gyp/pylib/gyp/generator/make.py 2019-05-07 14:52:16.000000000 +0000 ++++ node-v12.2.0+iPhone/tools/gyp/pylib/gyp/generator/make.py 2019-05-23 02:23:10.400738717 +0000 +@@ -173,8 +173,25 @@ + """ + + LINK_COMMANDS_MAC = """\ +-quiet_cmd_alink = LIBTOOL-STATIC $@ +-cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) ++quiet_cmd_alink = AR($(TOOLSET)) $@ ++cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) ++ ++quiet_cmd_alink_thin = AR($(TOOLSET)) $@ ++cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) ++ ++quiet_cmd_solink = SOLINK($(TOOLSET)) $@ ++cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) ++ ++quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ ++cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) ++""" ++ ++LINK_COMMANDS_IOS = """\ ++quiet_cmd_alink = AR($(TOOLSET)) $@ ++cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) ++ ++quiet_cmd_alink_thin = AR($(TOOLSET)) $@ ++cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) + + quiet_cmd_link = LINK($(TOOLSET)) $@ + cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) +@@ -2033,41 +2049,9 @@ + 'srcdir': srcdir, + 'copy_archive_args': copy_archive_arguments, + } +- if flavor == 'mac': +- flock_command = './gyp-mac-tool flock' +- header_params.update({ +- 'flock': flock_command, +- 'flock_index': 2, +- 'link_commands': LINK_COMMANDS_MAC, +- 'extra_commands': SHARED_HEADER_MAC_COMMANDS, +- }) +- elif flavor == 'android': +- header_params.update({ +- 'link_commands': LINK_COMMANDS_ANDROID, +- }) +- elif flavor == 'solaris': +- header_params.update({ +- 'flock': './gyp-flock-tool flock', +- 'flock_index': 2, +- }) +- elif flavor == 'freebsd': +- # Note: OpenBSD has sysutils/flock. lockf seems to be FreeBSD specific. +- header_params.update({ +- 'flock': 'lockf', +- }) +- elif flavor == 'openbsd': +- copy_archive_arguments = '-pPRf' +- header_params.update({ +- 'copy_archive_args': copy_archive_arguments, +- }) +- elif flavor == 'aix': +- copy_archive_arguments = '-pPRf' +- header_params.update({ +- 'copy_archive_args': copy_archive_arguments, +- 'link_commands': LINK_COMMANDS_AIX, +- 'flock': './gyp-flock-tool flock', +- 'flock_index': 2, +- }) ++ header_params.update({ ++ 'link_commands': LINK_COMMANDS_IOS, ++ }) + + header_params.update({ + 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), 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 new file mode 100644 index 000000000..a7c375eaf --- /dev/null +++ b/data/node/make.sh @@ -0,0 +1,36 @@ +pkg:setup + +export CC="${PKG_TARG}-gcc" +export CXX="${PKG_TARG}-g++" +export LD="${PKG_TARG}-ld" +export AR="${PKG_TARG}-ar" +export RANLIB="${PKG_TARG}-ranlib" +export AS="${PKG_TARG}-as" +export LINK="${CXX}" +export RANLIB="${PKG_TARG}-ranlib" +export SDKROOT="${PKG_ROOT}" +export LDFLAGS="-undefined dynamic_lookup" # libnode needs this- the binary will have the rest of the symbols. + +export CC_host="${HOSTCC:-clang}" +export CXX_host="${HOSTCXX:-clang++}" +export LINK_host="${CXX_host}" +export AR_host="${HOSTAR:-ar}" + +export CC_target="${CC}" +export CXX_target="${CXX}" +export LINK_target="${CXX}" # On purpose, see out/Makefile +export AR_target="${AR}" +export LDFLAGS_target="${LDFLAGS}" + +GYP_CROSSCOMPILE=1 \ +GYP_DEFINES="v8_enable_inspector=1 target_arch=arm64 v8_target_arch=arm64 host_os=$(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/') node_v8_options='--jitless'" \ +./configure --prefix="${PKG_TAPF}" --without-snapshot --cross-compiling --dest-os=ios --dest-cpu=arm64 --without-intl --shared-zlib --shared-cares --shared-openssl --shared + +# Don't use pkg:make, CC_host gets overwritten +make BUILDTYPE=Release DESTCPU=arm64 install DESTDIR="${PKG_DEST}" + +# TODO: Fix tool/install.py and the Makefile +if [[ ! -x "${PKG_TAPF}"/bin/node ]]; then + pkg: mkdir -p "${PKG_TAPF}"/bin + cp out/Release/node "${PKG_DEST}"/"${PKG_TAPF}"/bin +fi diff --git a/data/node/node-v12.3.1.tar.gz b/data/node/node-v12.3.1.tar.gz new file mode 100644 index 000000000..7c8799095 Binary files /dev/null and b/data/node/node-v12.3.1.tar.gz differ diff --git a/data/node/v8.diff b/data/node/v8.diff new file mode 100644 index 000000000..aed571fa6 --- /dev/null +++ b/data/node/v8.diff @@ -0,0 +1,167 @@ +diff -ur node-v12.3.1/deps/v8/src/arm64/cpu-arm64.cc node-v12.3.1+iPhone/deps/v8/src/arm64/cpu-arm64.cc +--- node-v12.3.1/deps/v8/src/arm64/cpu-arm64.cc 2019-05-22 12:21:52.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/v8/src/arm64/cpu-arm64.cc 2019-05-24 19:37:47.406732128 +0000 +@@ -15,7 +15,7 @@ + class CacheLineSizes { + public: + CacheLineSizes() { +-#if !defined(V8_HOST_ARCH_ARM64) || defined(V8_OS_WIN) ++#if !defined(V8_HOST_ARCH_ARM64) || defined(V8_OS_WIN) || defined(V8_OS_IPHONEOS) || defined(__IPHONEOS__) + cache_type_register_ = 0; + #else + // Copy the content of the cache type register to a core register. +diff -ur node-v12.3.1/deps/v8/src/base/platform/platform-posix.cc node-v12.3.1+iPhone/deps/v8/src/base/platform/platform-posix.cc +--- node-v12.3.1/deps/v8/src/base/platform/platform-posix.cc 2019-05-22 12:21:52.000000000 +0000 ++++ node-v12.3.1+iPhone/deps/v8/src/base/platform/platform-posix.cc 2019-05-24 19:40:15.582804009 +0000 +@@ -240,6 +240,8 @@ + // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance + // to fulfill request. + raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_ARM64 ++ raw_addr = raw_addr >> 14 << 14; + #else + raw_addr &= 0x3FFFF000; + +diff -ur node-v12.3.1/tools/v8_gypfiles/toolchain.gypi node-v12.3.1+iPhone/tools/v8_gypfiles/toolchain.gypi +--- node-v12.3.1/tools/v8_gypfiles/toolchain.gypi 2019-05-22 12:21:55.000000000 +0000 ++++ node-v12.3.1+iPhone/tools/v8_gypfiles/toolchain.gypi 2019-05-24 19:35:58.206678803 +0000 +@@ -84,7 +84,9 @@ + # The setting is ignored if want_separate_host_toolset is 0. + 'v8_toolset_for_shell%': 'target', + +- 'host_os%': '<(OS)', ++ # 'host_os%': '<(OS)', ++ 'host_os%': "