Ubuntu – Compile Chromium Browser for ARM (2019)

armchromecross-compilationdockerUbuntu

I've tried compiling Chromium for arm several times on Ubuntu 18, 16 and 14 but they all have their issues (mostly outdated-non existing packages). Building for amd64 has run perfectly, so I know the environments are relatively ok.

I've been follow this page but it doesn't go into to much depth.

I've tried making sense of this persons question but it's pretty outdated and extremely hard to follow.

Currently I've been following this with the most success https://www.olimex.com/forum/index.php?topic=4109.0

Here's the init docker file:

FROM ubuntu:xenial

RUN apt-get update && \
apt-get -y install build-essential \
                   git \
                   python \
                   gcc-arm-linux-gnueabihf \
                   g++-4.8-multilib-arm-linux-gnueabihf \
                   sudo

RUN apt-get -y install wget

RUN apt-get install -y python-software-properties \
                   software-properties-common

RUN apt-get update

RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections && \
apt-get install -y ttf-mscorefonts-installer

RUN apt-get install -y gcc-4.8-multilib g++-4.8-multilib

And here's the build script that runs inside docker:

#!/bin/sh

ROOT_DIR=/root
CHROM_DIR="$ROOT_DIR/chromium"

apt-get update

cd "$ROOT_DIR"
mkdir -pv "$CHROM_DIR"
cd "$CHROM_DIR"

git config --global user.name "[USER]" &&
git config --global user.email "[EMAIL]" &&
git config --global core.autocrlf false &&
git config --global core.filemode false &&
git config --global color.ui true &&
[ -d depot_tools ] || git clone https://chromium.googlesource.com/chromium/tools/depot_tools &&
PATH="$PATH:$CHROM_DIR/depot_tools" &&

BUILD_DIR="$CHROM_DIR/buildhost" &&
[ -d "$BUILD_DIR" ] || mkdir -v "$BUILD_DIR" &&
cd "$BUILD_DIR" &&

[ -d src ] || yes | fetch --nohooks --no-history chromium &&
cd src &&
rm -rf out &&

./build/install-build-deps.sh --no-prompt && 
yes | ./build/install-build-deps.sh --arm &&
./build/linux/sysroot_scripts/install-sysroot.py --arch=arm &&

mkdir out
mkdir out/arm

gclient sync && gclient runhooks &&

gn gen out/arm --args='is_official_build=true is_debug=false is_component_build=false symbol_level=0 enable_nacl=false blink_symbol_level=0 use_jumbo_build=true target_cpu="arm"'
gclient runhooks
autoninja -C out/arm chrome

This runs fine until I hit:

[8519/35281] STAMP obj/chrome/browser/resources/settings/unpak.stamp
[8520/35281] ACTION //third_party/blink/public:scaled_resources_100_percent(//build/toolchain/linux:clang_arm)
[8521/35281] ACTION //third_party/openscreen/src/osp/msgs:cddl_gen(//build/toolchain/linux:clang_arm)
FAILED: gen/third_party/openscreen/src/osp/msgs/osp_messages.h gen/third_party/openscreen/src/osp/msgs/osp_messages.cc 
python ../../third_party/openscreen/src/tools/cddl/cddl.py --header third_party/openscreen/src/osp/msgs/osp_messages.h --cc third_party/openscreen/src/osp/msgs/osp_messages.cc --gen-dir gen --log third_party/openscreen/src/osp/msgs/cddl.log ../../third_party/openscreen/src/osp/msgs/osp_messages.cddl
Traceback (most recent call last):
 File "../../third_party/openscreen/src/tools/cddl/cddl.py", line 116, in <module>
main()
File "../../third_party/openscreen/src/tools/cddl/cddl.py", line 37, in main
False, log, args.verbose)
File "../../third_party/openscreen/src/tools/cddl/cddl.py", line 84, in echoAndRunCommand
process = subprocess.Popen(commandArray, stdout=logfile, stderr=logfile)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
[8522/35281] ACTION //third_party/blink/public:scaled_resources_200_percent(//build/toolchain/linux:clang_arm)
[8523/35281] CXX obj/third_party/ots/ots/cff.o
[8524/35281] ACTION //chrome/browser/resources/downloads:build(//build/toolchain/linux:clang_arm)
[8525/35281] ACTION //chrome/browser/resources/extensions:build(//build/toolchain/linux:clang_arm)
[8526/35281] ACTION //chrome/browser/resources/print_preview:build(//build/toolchain/linux:clang_arm)
[8527/35281] ACTION //chrome/browser/resources/settings:build(//build/toolchain/linux:clang_arm)
ninja: build stopped: subcommand failed.

From what I've read, this means that something is trying to run for/from the wrong architecture.

Can someone please point me in the right direction?

Best Answer

Thanks to the openscreen author at Google, this is a known bug and one solution is to backport the fix to the chromium version being built or use 78.0.3890.0 or later.

I thought it would be easy to backport, but the commit that contains the fix also contains changes to the openscreen src structure that fail the build... I proceeded by carefully cherry-picking the fix by comparing the last two commits, and applying those changes to my chromium branch.

A workaround mentioned in the bug is to disable openscreen using the gn args "enable_opencreen=false".

Related Question