Add support for sub-architecture when building for iOS

Since iOS 7, the iPhone 5s, the iPad Air and the iPad Mini Retina
supports 64-bits binaries. This requires building a fat binary with
support for both armv7 and arm64 (and optionally armv7s).

In an effort to prepare building such a fat binary for Chrome on
iOS, introduce a "target_subarch" variable that control the variant
we want to build (32-bit only, 64-bit only -- mainly for debugging,
fat binary).

This require introducing way to use the clang compiler shipped with
Xcode, as the clang compiler shipped with Chromium code does not
support "arm64" architecture yet (Apple has not yet opensource the
implementation).

BUG=341453, 314720
R=mark@chromium.org

Review URL: https://codereview.chromium.org/156473005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251083 0039d316-1c4b-4281-b951-d872f2087c98
parent cbaf552f
...@@ -136,8 +136,9 @@ ...@@ -136,8 +136,9 @@
'host_arch%': '<(host_arch)', 'host_arch%': '<(host_arch)',
# Default architecture we're building for is the architecture we're # Default architecture we're building for is the architecture we're
# building on. # building on, and possibly sub-architecture (for iOS builds).
'target_arch%': '<(host_arch)', 'target_arch%': '<(host_arch)',
'target_subarch%': '',
# This is set when building the Android WebView inside the Android # This is set when building the Android WebView inside the Android
# build system, using the 'android' gyp backend. The WebView code is # build system, using the 'android' gyp backend. The WebView code is
...@@ -220,6 +221,18 @@ ...@@ -220,6 +221,18 @@
}, { }, {
'gomadir': '<!(/bin/echo -n ${HOME}/goma)', 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
}], }],
# Set the default "target_subarch" on iOS. Valid values are "arm32",
# "arm64" and "both" (meaning a fat binary).
#
# TODO(sdefresne): change the default from "arm32" to "both" for
# "target_subarch" once http://crbug.com/339477 is fixed.
#
# TODO(sdefresne): set the "target_arch" to "arm" once compilation
# of skia has been fixed for simulator. http://crbug.com/342377
['OS=="ios"', {
'target_subarch%': 'arm32',
}],
], ],
}, },
...@@ -227,6 +240,7 @@ ...@@ -227,6 +240,7 @@
'chromeos%': '<(chromeos)', 'chromeos%': '<(chromeos)',
'host_arch%': '<(host_arch)', 'host_arch%': '<(host_arch)',
'target_arch%': '<(target_arch)', 'target_arch%': '<(target_arch)',
'target_subarch%': '<(target_subarch)',
'toolkit_views%': '<(toolkit_views)', 'toolkit_views%': '<(toolkit_views)',
'toolkit_uses_gtk%': '<(toolkit_uses_gtk)', 'toolkit_uses_gtk%': '<(toolkit_uses_gtk)',
'desktop_linux%': '<(desktop_linux)', 'desktop_linux%': '<(desktop_linux)',
...@@ -866,6 +880,7 @@ ...@@ -866,6 +880,7 @@
'branding%': '<(branding)', 'branding%': '<(branding)',
'buildtype%': '<(buildtype)', 'buildtype%': '<(buildtype)',
'target_arch%': '<(target_arch)', 'target_arch%': '<(target_arch)',
'target_subarch%': '<(target_subarch)',
'host_arch%': '<(host_arch)', 'host_arch%': '<(host_arch)',
'toolkit_views%': '<(toolkit_views)', 'toolkit_views%': '<(toolkit_views)',
'ui_compositor_image_transport%': '<(ui_compositor_image_transport)', 'ui_compositor_image_transport%': '<(ui_compositor_image_transport)',
...@@ -1082,6 +1097,13 @@ ...@@ -1082,6 +1097,13 @@
'clang%': '<(clang)', 'clang%': '<(clang)',
'make_clang_dir%': 'third_party/llvm-build/Release+Asserts', 'make_clang_dir%': 'third_party/llvm-build/Release+Asserts',
# Control which version of clang to use when 'clang' is set to 1 when
# building for iOS (Apple has not yet open-sourced support for "arm64"
# so when building for that 'target_arch' we have to use clang shipped
# with Xcode that does not supports some flags).
# TODO(sdefresne): remove this once http://crbug.com/341453 is fixed.
'clang_xcode%': 0,
# These two variables can be set in GYP_DEFINES while running # These two variables can be set in GYP_DEFINES while running
# |gclient runhooks| to let clang run a plugin in every compilation. # |gclient runhooks| to let clang run a plugin in every compilation.
# Only has an effect if 'clang=1' is in GYP_DEFINES as well. # Only has an effect if 'clang=1' is in GYP_DEFINES as well.
...@@ -1729,7 +1751,13 @@ ...@@ -1729,7 +1751,13 @@
['"<(GENERATOR)"=="ninja"', { ['"<(GENERATOR)"=="ninja"', {
'clang%': 1, 'clang%': 1,
'host_os%': "mac", 'host_os%': "mac",
}] }],
# Apple has not upstreamed the support for "arm64" yet, so when
# building for "arm64" or "both", we need to use the clang that
# is provided with Xcode.
['target_subarch!="arm32"', {
'clang_xcode%': 1,
}],
], ],
}], }],
['enable_extensions==1', { ['enable_extensions==1', {
...@@ -4033,9 +4061,6 @@ ...@@ -4033,9 +4061,6 @@
# Note that the prebuilt Clang binaries should not be used for iOS # Note that the prebuilt Clang binaries should not be used for iOS
# development except for ASan builds. # development except for ASan builds.
['clang==1', { ['clang==1', {
'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang',
'LDPLUSPLUS': '$(SOURCE_ROOT)/<(clang_dir)/clang++',
# gnu++11 instead of c++11 is needed because some code uses # gnu++11 instead of c++11 is needed because some code uses
# typeof() (a GNU extension). # typeof() (a GNU extension).
# TODO(thakis): Eventually switch this to c++11 instead of # TODO(thakis): Eventually switch this to c++11 instead of
...@@ -4070,24 +4095,37 @@ ...@@ -4070,24 +4095,37 @@
# Warns when a const char[] is converted to bool. # Warns when a const char[] is converted to bool.
'-Wstring-conversion', '-Wstring-conversion',
],
# Clang considers the `register` keyword as deprecated, but e.g. 'conditions': [
# code generated by flex (used in angle) contains that keyword. ['clang_xcode==0', {
# http://crbug.com/255186 'CC': '$(SOURCE_ROOT)/<(clang_dir)/clang',
'-Wno-deprecated-register', 'LDPLUSPLUS': '$(SOURCE_ROOT)/<(clang_dir)/clang++',
'WARNING_CFLAGS': [
# Clang considers the `register` keyword as deprecated, but
# e.g. code generated by flex (used in angle) contains that
# keyword. http://crbug.com/255186
#
# Note: clang as shipped with Xcode is older and does not
# treat the `register` as deprecated and does not define
# this flag, so don't enable it if "clang_xcode" is "1".
'-Wno-deprecated-register',
],
}],
], ],
}], }],
['clang==1 and clang_use_chrome_plugins==1', { ['clang==1 and clang_xcode==0 and clang_use_chrome_plugins==1', {
'OTHER_CFLAGS': [ 'OTHER_CFLAGS': [
'<@(clang_chrome_plugins_flags)', '<@(clang_chrome_plugins_flags)',
], ],
}], }],
['clang==1 and clang_load!=""', { ['clang==1 and clang_xcode==0 and clang_load!=""', {
'OTHER_CFLAGS': [ 'OTHER_CFLAGS': [
'-Xclang', '-load', '-Xclang', '<(clang_load)', '-Xclang', '-load', '-Xclang', '<(clang_load)',
], ],
}], }],
['clang==1 and clang_add_plugin!=""', { ['clang==1 and clang_xcode==0 and clang_add_plugin!=""', {
'OTHER_CFLAGS': [ 'OTHER_CFLAGS': [
'-Xclang', '-add-plugin', '-Xclang', '<(clang_add_plugin)', '-Xclang', '-add-plugin', '-Xclang', '<(clang_add_plugin)',
], ],
...@@ -4368,14 +4406,32 @@ ...@@ -4368,14 +4406,32 @@
# Match OS X clang C++11 warning settings. # Match OS X clang C++11 warning settings.
'-Wno-c++11-narrowing', '-Wno-c++11-narrowing',
], ],
# Limit the valid architectures depending on "target_subarch".
# This need to include the "arm" architectures but also the "x86"
# ones (they are used when building for the simulator).
'conditions': [
['target_subarch=="arm32"', {
'VALID_ARCHS': ['armv7', 'i386'],
}],
['target_subarch=="arm64"', {
'VALID_ARCHS': ['arm64', 'x86_64'],
}],
['target_subarch=="both"', {
'VALID_ARCHS': ['arm64', 'armv7', 'x86_64', 'i386'],
}],
],
}, },
'target_conditions': [ 'target_conditions': [
['_toolset=="host"', { ['_toolset=="host"', {
'xcode_settings': { 'xcode_settings': {
'SDKROOT': 'macosx<(mac_sdk)', # -isysroot 'SDKROOT': 'macosx<(mac_sdk)', # -isysroot
'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)', 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
'VALID_ARCHS': [
'x86_64',
],
'ARCHS': [ 'ARCHS': [
'x86_64' 'x86_64',
], ],
}, },
}], }],
...@@ -4385,6 +4441,7 @@ ...@@ -4385,6 +4441,7 @@
# since we can't negate the iphone deployment target above, we # since we can't negate the iphone deployment target above, we
# instead set it here for target only. # instead set it here for target only.
'IPHONEOS_DEPLOYMENT_TARGET': '<(ios_deployment_target)', 'IPHONEOS_DEPLOYMENT_TARGET': '<(ios_deployment_target)',
'ARCHS': ['$(ARCHS_STANDARD_INCLUDING_64_BIT)'],
}, },
}], }],
['_type=="executable"', { ['_type=="executable"', {
...@@ -4803,7 +4860,8 @@ ...@@ -4803,7 +4860,8 @@
], ],
}, },
}], }],
['clang==1 and OS!="win"', { ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
'and OS!="win"', {
'make_global_settings': [ 'make_global_settings': [
['CC', '<(make_clang_dir)/bin/clang'], ['CC', '<(make_clang_dir)/bin/clang'],
['CXX', '<(make_clang_dir)/bin/clang++'], ['CXX', '<(make_clang_dir)/bin/clang++'],
...@@ -4839,7 +4897,8 @@ ...@@ -4839,7 +4897,8 @@
# TODO(yyanagisawa): supports GENERATOR==make # TODO(yyanagisawa): supports GENERATOR==make
# make generator doesn't support CC_wrapper without CC # make generator doesn't support CC_wrapper without CC
# in make_global_settings yet. # in make_global_settings yet.
['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', { ['use_goma==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) and '
'("<(GENERATOR)"=="ninja" or clang==1)', {
'make_global_settings': [ 'make_global_settings': [
['CC_wrapper', '<(gomadir)/gomacc'], ['CC_wrapper', '<(gomadir)/gomacc'],
['CXX_wrapper', '<(gomadir)/gomacc'], ['CXX_wrapper', '<(gomadir)/gomacc'],
...@@ -4887,7 +4946,6 @@ ...@@ -4887,7 +4946,6 @@
['OS=="ios"', { ['OS=="ios"', {
# Target both iPhone and iPad. # Target both iPhone and iPad.
'TARGETED_DEVICE_FAMILY': '1,2', 'TARGETED_DEVICE_FAMILY': '1,2',
'VALID_ARCHS': 'armv7 i386',
}, { # OS!="ios" }, { # OS!="ios"
'conditions': [ 'conditions': [
['target_arch=="x64"', { ['target_arch=="x64"', {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment