summaryrefslogtreecommitdiffstats
path: root/meta-html5-framework/recipes-wam/chromium/gn-utils.inc
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2019-06-17 13:12:00 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2019-06-20 12:57:47 +0000
commite6cc8d4e0977b4a3dda28c70caea3515f9d07edd (patch)
tree37493398c6f35728ca73cc36c64e91e9bed33c1a /meta-html5-framework/recipes-wam/chromium/gn-utils.inc
parent13e42025cf8c2b6f5b8d10666353e60da7d52370 (diff)
chromium68: custom toolchain, target v8 snapshot
Modify the chromium68 recipe to make it more like the one available in meta-browser: https://github.com/OSSystems/meta-browser Instead of passing Yocto's build flags to the cros (=ChromeOS) toolchain, generate a toolchain definition file specifically for this build. For the generation of the V8 memory snapshot, build the required files for the target architecture, then use qemu-native to run them. Upstream chromium addresses this problem by downloading a specific native toolchain for every target platform, which we cannot do in this context. The toolchain changes trigger an issue with ARMv7 builds; backported one patch to address that specific issue. This changes also triggered a problem with 32 bit targets, the generated binaries were too big. Forced the DEBUG_ARGS to use -g1 (or -g0 otherwise). Bug-AGL: SPEC-2514 Change-Id: Ib18431b628415c58a3c29595bfff10057e355a4b Signed-off-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Diffstat (limited to 'meta-html5-framework/recipes-wam/chromium/gn-utils.inc')
-rw-r--r--meta-html5-framework/recipes-wam/chromium/gn-utils.inc75
1 files changed, 61 insertions, 14 deletions
diff --git a/meta-html5-framework/recipes-wam/chromium/gn-utils.inc b/meta-html5-framework/recipes-wam/chromium/gn-utils.inc
index bca7af8d..0fd55a63 100644
--- a/meta-html5-framework/recipes-wam/chromium/gn-utils.inc
+++ b/meta-html5-framework/recipes-wam/chromium/gn-utils.inc
@@ -16,20 +16,67 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-def gn_arch_name(yocto_arch):
- """Translates between Yocto's architecture values and the corresponding
- ones used by GN."""
- translation_table = {
- 'aarch64': 'arm64',
- 'arm': 'arm',
- 'i586': 'x86',
- 'x86_64': 'x64',
+# GN host architecture helpers.
+#
+# BUILD_ARCH's value corresponds to what uname returns as the machine name.
+# The mapping in gn_host_arch_name() tries to match several possible values
+# returned by the Linux kernel in uname(2) into the corresponding values GN
+# understands.
+def gn_host_arch_name(d):
+ """Returns a GN architecture name corresponding to the build host's machine
+ architecture."""
+ import re
+ arch_translations = {
+ r'aarch64.*': 'arm64',
+ r'arm.*': 'arm',
+ r'i[3456]86$': 'x86',
+ r'x86_64$': 'x64',
}
- try:
- return translation_table[yocto_arch]
- except KeyError:
- bb.msg.fatal('"%s" is not a supported architecture.' % yocto_arch)
+ build_arch = d.getVar("BUILD_ARCH")
+ for arch_regexp, gn_arch_name in arch_translations.items():
+ if re.match(arch_regexp, build_arch):
+ return gn_arch_name
+ bb.fatal('Unsuported BUILD_ARCH value: "%s"' % build_arch)
+
+# GN target architecture helpers.
+#
+# Determining the target architecture is more difficult, as there are many
+# different values we can use on the Yocto side (e.g. TUNE_ARCH, TARGET_ARCH,
+# MACHINEOVERRIDES etc). What we do is define the mapping with regular,
+# non-Python variables with overrides that are generic enough (i.e. "x86"
+# instead of "i586") and then use gn_target_arch_name() to return the right
+# value with some validation.
+GN_TARGET_ARCH_NAME_aarch64 = "arm64"
+GN_TARGET_ARCH_NAME_arm = "arm"
+GN_TARGET_ARCH_NAME_x86 = "x86"
+GN_TARGET_ARCH_NAME_x86-64 = "x64"
+
+BUILD_CC_toolchain-clang = "clang"
+BUILD_CXX_toolchain-clang = "clang++"
+BUILD_LD_toolchain-clang = "clang"
+
+# knob for clang, when using meta-clang to provide clang and case where
+# clang happens to be default compiler for OE we should let it use clang
+def is_default_cc_clang(d):
+ """Return true if clang is default cross compiler."""
+ toolchain = d.getVar("TOOLCHAIN")
+ overrides = d.getVar("OVERRIDES")
+ if toolchain == "clang" and "toolchain-clang" in overrides.split(":"):
+ return "true"
+ return "false"
+
+def clang_install_path(d):
+ """Return clang compiler install path."""
+ return d.getVar("STAGING_BINDIR_NATIVE")
+def gn_target_arch_name(d):
+ """Returns a GN architecture name corresponding to the target machine's
+ architecture."""
+ name = d.getVar("GN_TARGET_ARCH_NAME")
+ if name is None:
+ bb.fatal('Unsupported target architecture. A valid override for the '
+ 'GN_TARGET_ARCH_NAME variable could not be found.')
+ return name
def write_toolchain_file(d, file_path):
"""Creates a complete GN toolchain file in |file_path|."""
@@ -70,7 +117,7 @@ def write_toolchain_file(d, file_path):
native_toolchain = {
'toolchain_name': 'yocto_native',
- 'current_cpu': gn_arch_name(d.getVar('BUILD_ARCH', True)),
+ 'current_cpu': gn_host_arch_name(d),
'cc': d.expand('${BUILD_CC}'),
'cxx': d.expand('${BUILD_CXX}'),
'ar': d.expand('${BUILD_AR}'),
@@ -83,7 +130,7 @@ def write_toolchain_file(d, file_path):
}
target_toolchain = {
'toolchain_name': 'yocto_target',
- 'current_cpu': gn_arch_name(d.getVar('TUNE_ARCH', True)),
+ 'current_cpu': gn_target_arch_name(d),
'cc': d.expand('${CC}'),
'cxx': d.expand('${CXX}'),
'ar': d.expand('${AR}'),