diff options
author | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2021-01-12 05:47:34 -0500 |
---|---|---|
committer | Jonathan Buchanan <jonathan.russ.buchanan@gmail.com> | 2021-01-12 05:47:34 -0500 |
commit | e046b4133c98e830c445f36554030a0656567bcf (patch) | |
tree | 76f3a02ea1566507a508bba301c433c36daa5fe0 | |
parent | 23af36d99ea59d934c38ca8a69536119c49bac7f (diff) | |
download | ios-node-v8-e046b4133c98e830c445f36554030a0656567bcf.tar.gz ios-node-v8-e046b4133c98e830c445f36554030a0656567bcf.tar.bz2 ios-node-v8-e046b4133c98e830c445f36554030a0656567bcf.zip |
edit build process so node runs properly on ios
-rw-r--r-- | common.gypi | 10 | ||||
-rw-r--r-- | node.gyp | 30 | ||||
-rw-r--r-- | node.gypi | 2 | ||||
-rw-r--r-- | src/node.cc | 2 | ||||
-rw-r--r-- | taler-ios-build/README | 3 | ||||
-rwxr-xr-x | taler-ios-build/arm64 | 18 | ||||
-rwxr-xr-x | taler-ios-build/build-ios-node | 9 | ||||
-rwxr-xr-x | taler-ios-build/build-ios-v8 | 43 | ||||
-rwxr-xr-x | taler-ios-build/x64 | 18 | ||||
-rw-r--r-- | tools/gyp/pylib/gyp/generator/make.py | 36 | ||||
-rw-r--r-- | tools/gyp/pylib/gyp/xcode_emulation.py | 5 | ||||
-rw-r--r-- | tools/v8_gypfiles/toolchain.gypi | 19 |
12 files changed, 76 insertions, 119 deletions
diff --git a/common.gypi b/common.gypi index a221cb84e1..1891758117 100644 --- a/common.gypi +++ b/common.gypi @@ -103,12 +103,10 @@ }, { 'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)', }], - ['OS=="mac"', { - 'obj_dir%': '<(PRODUCT_DIR)/obj.target', - 'v8_base': '<(PRODUCT_DIR)/libv8_snapshot.a', - }], ['OS=="mac" or OS=="ios"', { 'clang%': 1, + 'obj_dir%': '<(PRODUCT_DIR)/obj.target', + 'v8_base': '<(PRODUCT_DIR)/libv8_snapshot.a', }], ['target_arch in "ppc64 s390x"', { 'v8_enable_backtrace': 1, @@ -195,7 +193,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"', { @@ -321,7 +319,7 @@ [ 'target_arch=="arm64"', { 'msvs_configuration_platform': 'arm64', }], - ['asan == 1 and OS != "mac"', { + ['asan == 1 and OS != "mac" and OS != "ios"', { 'cflags+': [ '-fno-omit-frame-pointer', '-fsanitize=address', @@ -441,7 +441,7 @@ }, }, 'conditions': [ - ['OS != "aix" and OS != "mac"', { + ['OS != "aix" and OS != "mac" and OS != "ios"', { 'ldflags': [ '-Wl,--whole-archive', '<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)', @@ -522,10 +522,6 @@ ], }, ], - }, { - 'sources': [ - 'src/node_code_cache_stub.cc' - ], }], ['node_use_node_snapshot=="true"', { 'dependencies': [ @@ -547,10 +543,6 @@ ], }, ], - }, { - 'sources': [ - 'src/node_snapshot_stub.cc' - ], }], [ 'OS in "linux freebsd" and ' 'target_arch=="x64"', { @@ -821,6 +813,18 @@ 'src/node_code_cache_stub.cc', ] }], + [ 'node_target_type=="static_library" and OS=="ios"', { + 'sources': [ + 'src/node_snapshot_stub.cc', + 'src/node_code_cache_stub.cc', + ] + }], + [ 'node_target_type!="static_library" and OS=="ios"', { + 'sources': [ + 'src/node_snapshot_stub.cc', + 'src/node_code_cache_stub.cc', + ] + }], [ 'node_shared=="true" and node_module_version!="" and OS!="win"', { 'product_extension': '<(shlib_suffix)', 'xcode_settings': { @@ -908,7 +912,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', @@ -970,7 +974,7 @@ 'src/node_crypto.h' ], }], - [ 'OS in "linux freebsd mac solaris" and ' + [ 'OS in "linux freebsd mac ios solaris" and ' 'target_arch=="x64" and ' 'node_target_type=="executable"', { 'defines': [ 'NODE_ENABLE_LARGE_CODE_PAGES=1' ], @@ -1126,7 +1130,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', @@ -1161,7 +1165,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', @@ -313,7 +313,7 @@ ], }, }], - [ 'coverage=="true" and node_shared=="false" and OS in "mac freebsd linux"', { + [ 'coverage=="true" and node_shared=="false" and OS in "mac ios freebsd linux"', { 'cflags!': [ '-O3' ], 'ldflags': [ '--coverage', '-g', diff --git a/src/node.cc b/src/node.cc index c3f423cb57..6256795fcc 100644 --- a/src/node.cc +++ b/src/node.cc @@ -744,6 +744,7 @@ void ResetStdio() { CHECK_NE(err, -1); } +#if !(defined(__APPLE__) && TARGET_OS_IPHONE) if (s.isatty) { sigset_t sa; int err; @@ -763,6 +764,7 @@ void ResetStdio() { // tcsetattr will fail with err == -1 and errno == EPERM. CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM); } +#endif } #endif // __POSIX__ } diff --git a/taler-ios-build/README b/taler-ios-build/README new file mode 100644 index 0000000000..1ade42ef2e --- /dev/null +++ b/taler-ios-build/README @@ -0,0 +1,3 @@ +Node is built with the stub versions of the node code cache and node snapshots +for ios. Also, v8 is always called with --jitless because jit is not allowed +by Apple. diff --git a/taler-ios-build/arm64 b/taler-ios-build/arm64 index 8668039ded..b5c3f87928 100755 --- a/taler-ios-build/arm64 +++ b/taler-ios-build/arm64 @@ -5,20 +5,6 @@ set -eu -o pipefail scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" cd $scriptdir -API_LEVEL=21 -BUILD_HOST_TAG='mac-x86_64' - -########## -# Build V8 -########## - -./build-ios-v8 arm64 - -cd $scriptdir/.. -x=$scriptdir/compiled/arm64-v8a/ -mkdir -p $x -cp deps/v8/out.gn/ios-arm64/obj/*.a $x/ - ############ # Build Node ############ @@ -30,6 +16,6 @@ cd $scriptdir ./build-ios-node arm64 cd $scriptdir/.. -x=$scriptdir/compiled/arm64-v8a/ +x=$scriptdir/compiled/node-arm64/ mkdir -p $x -cp out/Release/libnode.*.dylib $x/ +cp out/Release/*.a $x/ diff --git a/taler-ios-build/build-ios-node b/taler-ios-build/build-ios-node index 2bf5e71a1e..573ceff867 100755 --- a/taler-ios-build/build-ios-node +++ b/taler-ios-build/build-ios-node @@ -8,18 +8,19 @@ set -eu -o pipefail scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" cd $scriptdir/.. -export GYP_DEFINES="OS=ios clang=1" +export GYP_DEFINES="target_arch=$DEST_CPU_ARCH host_os=mac target_os=ios" function myconf() { ./configure \ - --ninja \ --cross-compiling \ --dest-cpu=$DEST_CPU_ARCH \ --dest-os=ios \ --without-intl \ --openssl-no-asm \ - --without-bundled-v8 \ - --shared + --v8-options=--jitless \ + --enable-static \ + --without-node-code-cache \ + --without-node-snapshot } myconf && make diff --git a/taler-ios-build/build-ios-v8 b/taler-ios-build/build-ios-v8 deleted file mode 100755 index 23471dca12..0000000000 --- a/taler-ios-build/build-ios-v8 +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" -cd $scriptdir/.. - -DEST_CPU_ARCH=$1 - -# We do not export anything about the tool chain, as v8 -# will pick their own toolchain for android from the ndk - -cd ./deps/v8 - -python3 ./tools/node/fetch_deps.py $PWD - -gn_args=$(cat <<EOF -is_official_build = true -v8_enable_backtrace = false -v8_enable_slow_dchecks = true -v8_optimized_debug = false -ios_deployment_target = 10 -is_component_build = false -is_debug = false -target_cpu = "$DEST_CPU_ARCH" -target_os = "ios" -use_custom_libcxx = false -use_xcode_clang = true -v8_enable_i18n_support = false -v8_monolithic = true -v8_use_external_startup_data = false -EOF -) - -echo gn_args $gn_args - -echo "executing gn gen" - -./buildtools/mac/gn gen out.gn/ios-$DEST_CPU_ARCH "--args=$gn_args" - -echo "executing ninja" - -./_depot_tools/ninja -C out.gn/ios-$DEST_CPU_ARCH v8_monolith d8 diff --git a/taler-ios-build/x64 b/taler-ios-build/x64 index f7d01f2f68..5e5043e167 100755 --- a/taler-ios-build/x64 +++ b/taler-ios-build/x64 @@ -5,20 +5,6 @@ set -eu -o pipefail scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" cd $scriptdir -API_LEVEL=21 -BUILD_HOST_TAG='mac-x86_64' - -########## -# Build V8 -########## - -./build-ios-v8 x64 - -cd $scriptdir/.. -x=$scriptdir/compiled/x64-v8a/ -mkdir -p $x -cp deps/v8/out.gn/ios-x64/*.so $x/ - ############ # Build Node ############ @@ -30,6 +16,6 @@ cd $scriptdir ./build-ios-node x64 cd $scriptdir/.. -x=$scriptdir/compiled/x64-v8a/ +x=$scriptdir/compiled/node-x64/ mkdir -p $x -cp out/Release/libnode.*.dylib $x/ +cp out/Release/*.a $x/ diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index d163ae3135..5a63108e63 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -66,7 +66,7 @@ generator_filelist_paths = None def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" flavor = gyp.common.GetFlavor(params) - if flavor == "mac": + if flavor == "mac" or flavor == "ios": default_variables.setdefault("OS", "mac") default_variables.setdefault("SHARED_LIB_SUFFIX", ".dylib") default_variables.setdefault( @@ -758,7 +758,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD self.toolset = spec["toolset"] self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) else: self.xcode_settings = None @@ -953,7 +953,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD # Write the actual command. action_commands = action["action"] - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": action_commands = [ gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action_commands @@ -1127,7 +1127,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD # action, cd_action, and mkdirs get written to a toplevel variable # called cmd_foo. Toplevel variables can't handle things that change # per makefile like $(TARGET), so hardcode the target. - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": action = [ gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action @@ -1298,7 +1298,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD quoter=EscapeCppDefine, ) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": cflags = self.xcode_settings.GetCflags( configname, arch=config.get('xcode_configuration_platform') @@ -1318,7 +1318,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD self.WriteList(cflags_c, "CFLAGS_C_%s" % configname) self.WriteLn("# Flags passed to only C++ files.") self.WriteList(cflags_cc, "CFLAGS_CC_%s" % configname) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": self.WriteLn("# Flags passed to only ObjC files.") self.WriteList(cflags_objc, "CFLAGS_OBJC_%s" % configname) self.WriteLn("# Flags passed to only ObjC++ files.") @@ -1389,7 +1389,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD "%s " % precompiled_header.GetInclude("cc") + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_CC_$(BUILDTYPE))" ) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": self.WriteLn( "$(OBJS): GYP_OBJCFLAGS := " "$(DEFS_$(BUILDTYPE)) " @@ -1456,7 +1456,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD """ assert not self.is_mac_bundle - if self.flavor == "mac" and self.type in ( + if (self.flavor == "mac" or self.flavor == "ios") and self.type in ( "static_library", "executable", "shared_library", @@ -1502,7 +1502,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD def _InstallImmediately(self): return ( self.toolset == "target" - and self.flavor == "mac" + and (self.flavor == "mac" or self.flavor == "ios") and self.type in ("static_library", "executable", "shared_library", "loadable_module") ) @@ -1592,7 +1592,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD if self.type != "none": for configname in sorted(configs.keys()): config = configs[configname] - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": ldflags = self.xcode_settings.GetLdflags( configname, generator_default_variables["PRODUCT_DIR"], @@ -1626,7 +1626,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD library_dirs = config.get("library_dirs", []) ldflags += [("-L%s" % library_dir) for library_dir in library_dirs] self.WriteList(ldflags, "LDFLAGS_%s" % configname) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": self.WriteList( self.xcode_settings.GetLibtoolflags(configname), "LIBTOOLFLAGS_%s" % configname, @@ -1635,7 +1635,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD if libraries: # Remove duplicate entries libraries = gyp.common.uniquer(libraries) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": libraries = self.xcode_settings.AdjustLibraries(libraries) self.WriteList(libraries, "LIBS") self.WriteLn( @@ -1644,7 +1644,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD ) self.WriteLn("%s: LIBS := $(LIBS)" % QuoteSpaces(self.output_binary)) - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": self.WriteLn( "%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))" % QuoteSpaces(self.output_binary) @@ -1653,7 +1653,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD # Postbuild actions. Like actions, but implicitly depend on the target's # output. postbuilds = [] - if self.flavor == "mac": + if self.flavor == "mac" or self.flavor == "ios": if target_postbuilds: postbuilds.append("$(TARGET_POSTBUILDS_$(BUILDTYPE))") postbuilds.extend(gyp.xcode_emulation.GetSpecPostbuildCommands(spec)) @@ -1763,7 +1763,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD "Spaces in alink input filenames not supported (%s)" % link_dep ) if ( - self.flavor not in ("mac", "openbsd", "netbsd", "win") + self.flavor not in ("mac", "ios", "openbsd", "netbsd", "win") and not self.is_standalone_static_library ): self.WriteDoCmd( @@ -1855,7 +1855,7 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD install_path = self._InstallableTargetInstallPath() installable_deps = [self.output] if ( - self.flavor == "mac" + (self.flavor == "mac" or self.flavor == "ios") and "product_dir" not in spec and self.toolset == "target" ): @@ -2296,7 +2296,7 @@ def GenerateOutput(target_list, target_dicts, data, params): "CXX.host": GetEnvironFallback(("CXX_host", "CXX"), "g++"), "LINK.host": GetEnvironFallback(("LINK_host", "LINK"), "$(CXX.host)"), } - if flavor == "mac": + if flavor == "mac" or flavor == "ios": flock_command = "./gyp-mac-tool flock" header_params.update( { @@ -2444,7 +2444,7 @@ def GenerateOutput(target_list, target_dicts, data, params): spec = target_dicts[qualified_target] configs = spec["configurations"] - if flavor == "mac": + if flavor == "mac" or flavor == "ios": gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) writer = MakefileWriter(generator_flags, flavor) diff --git a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py index 8af2b39f9a..010042111f 100644 --- a/tools/gyp/pylib/gyp/xcode_emulation.py +++ b/tools/gyp/pylib/gyp/xcode_emulation.py @@ -558,8 +558,7 @@ class XcodeSettings(object): return XcodeSettings._sdk_path_cache[sdk_root] def _AppendPlatformVersionMinFlags(self, lst): - self._Appendf(lst, "MACOSX_DEPLOYMENT_TARGET", "-mmacosx-version-min=%s") - if "IPHONEOS_DEPLOYMENT_TARGET" in self._Settings(): + if "IPHONEOS_DEPLOYMENT_TARGET" in self._Settings() and self._Settings()['IPHONEOS_DEPLOYMENT_TARGET']: # TODO: Implement this better? sdk_path_basename = os.path.basename(self._SdkPath()) if sdk_path_basename.lower().startswith("iphonesimulator"): @@ -570,6 +569,8 @@ class XcodeSettings(object): self._Appendf( lst, "IPHONEOS_DEPLOYMENT_TARGET", "-miphoneos-version-min=%s" ) + else: + self._Appendf(lst, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') def GetCflags(self, configname, arch=None): """Returns flags that need to be added to .c, .cc, .m, and .mm diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index 1422c91ec4..ade7ae9fd0 100644 --- a/tools/v8_gypfiles/toolchain.gypi +++ b/tools/v8_gypfiles/toolchain.gypi @@ -1099,6 +1099,25 @@ }], ], }], + ['OS=="ios"', { + 'target_conditions': [ + ['_toolset=="host" and host_os=="mac"', { + 'xcode_settings': { + 'SDKROOT': '', + 'IPHONEOS_DEPLOYMENT_TARGET': '', + 'MACOSX_DEPLOYMENT_TARGET': '10.10', + }, + 'conditions':[ + ['target_arch=="arm64"', { + 'xcode_settings': { + 'ARCHS!': ['arm64'], + 'ARCHS': ['x86_64'], + }, + }], + ], + }], + ] + }], ], # conditions 'configurations': { 'Debug': { |