Cross-compiling Berkelium for ARMv6 with Emdebian Toolchain

Berkelium is a BSD licensed library that provides off-screen browser rendering via Google’s open source Chromium web browser.

This library is used by Xibo Digital Signage Player python client and I already cross-compiled it using Ubuntu/Linaro  toolchain. Since I need it to run on ARMv6 for the Raspberry Pi, I have cross-compiled it again in Debian with Emdebian ARM cross-compiler.

Here are the instructions I followed to build Berkelium and Chromium for ARMv6 in Debian.

First, you’ll need to install some development libraries for ARM:

sudo /usr/share/pdebuild-cross/xapt -a armel libnss3-dev libgconf2-dev libgnome-keyring-dev libgtk2.0-dev libgnome-keyring-dev libgtk2.0-dev libxtst-dev libpam-dev libxss-dev libdbus-glib-1-dev libnss3-dev libgconf2-dev libgnome-keyring-dev libxss-dev libdbus-glib-1-dev libnspr4-dev libglib2.0-dev libjpeg-dev libasound2-dev libbz2-dev libgcrypt-dev libspeex-dev libcups2-dev

and some tools on the build machine:
sudo apt-get install git-core subversion cmake doxygen gyp gperf flex bison

On 64-bit build machines (required for debug build) also install g++-multi and possibly some 32-bit libraries with xapt:


If you don’t, you’ll get the following error:

LINK(host) out/Release/mksnapshot
/usr/bin/ld: warning: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so while searching for stdc++
/usr/bin/ld: error: cannot find -lstdc++

Then retrieve berkelium source code (I’ve done that in ~/edev/raspberry-pi directory):

git clone git://github.com/sirikata/berkelium.git
cd berkelium/externals
git clone git://github.com/sirikata/cxxtest.git

You’ll also need to install tools specific to Chromium (gclient):

cd  ~/edev/raspberry-pi/berkelium/build/
svn co http://src.chromium.org/svn/trunk/tools/depot_tools

In ~/edev/raspberry-pi/berkelium/, I’ve created arm.env with the environment variables required to build chromium and berkelium:

export CROSSTOOL=arm-linux-gnueabi
export CXX=$CROSSTOOL-g++
export CC=$CROSSTOOL-gcc
export AR=$CROSSTOOL-ar
export AS=$CROSSTOOL-as
export RANLIB=$CROSSTOOL-ranlib

export CFLAGS=”-I/usr/arm-linux-gnueabi/include/gtk-2.0 -I/usr/arm-linux-gnueabi/include/glib-2.0 -march=armv6 -mfpu=vfp -mfloat-abi=softfp”

export CCFLAGS=$CFLAGS

export CXXFLAGS=”-I/usr/arm-linux-gnueabi/include/gtk-2.0 -I/usr/arm-linux-gnueabi/include/glib-2.0/ -I/usr/arm-linux-gnueabi/lib/glib-2.0/include/ -I/usr/arm-linux-gnueabi/include/pango-1.0 -I/usr/arm-linux-gnueabi/include/cairo/ -I/usr/arm-linux-gnueabi/include/librsvg-2 -O3  -march=armv6 -mfpu=vfp -mfloat-abi=softfp”

export GYP_DEFINES=”target_arch=arm disable_nacl=1 linux_use_tcmalloc=0 armv6=1 arm_thumb=0 use_libjpeg_turbo=0″

I also had to create ~/.gyp/include.gypi:

{
'variables': {
'target_arch': 'arm',
'disable_nacl': 1,  # NaCL does not build for ARM.
'linux_use_tcmalloc': 0, # tcmalloc does not build for ARM.
'armv7': 0, # Optional, for targeting ARMv7.
'armv6': 1, # Optional, for targeting ARMv7.
'arm_thumb': 0, # Optional, for targeting thumb.  Combine with armv7 to target thumb2.
'arm_neon': 0, # Optional, to disable NEON. 1 is the default, and most people want to keep it that way.
'arm_fpu': 'vfp', # Optional, to select which version of vfp to use if NEON is off. Default is vfpv3.
'verbose': 1
}
}

Once this is done,  source the environment variables, and start the script to checkout and build the code:

source arm.env
./util/build-chromium.sh

I would recommend that you also export V=1 in order to see the arm-linux-gnueabi-xxx command line used. This will greatly help if case the build fails.

After the checkout part is completed and compilation start (CXX messages appear), you can stop the build with Ctrl+C and modify 2 gyp files to be able to compile as Emdebian compiler defaults to armv4 architecture which is not supported by Chromium:

  • 1 line at line 851 in build/chromium/src/skia/skia.gyp:
    ‘cflags’: [
    ‘-fomit-frame-pointer’,
                   ‘-march=armv6 -mfpu=vfp -mfloat-abi=softfp’,
    ],
  • 5 lines at line 621 in build/chromium/src/v8/tools/gyp/v8.gyp:
    ‘conditions’: [
    # The ARM assembler assumes the host is 32 bits,
    # so force building 32-bit host tools.
    [‘host_arch==”x64″ and _toolset==”host”‘, {
    ‘cflags’: [‘-m32’],
    ‘ldflags’: [‘-m32’],
    }],
                    [‘_toolset==”target”‘, {
                      ‘cflags’: [‘-march=armv6’,
                                 ‘-mfpu=vfp’,
                                 ‘-mfloat-abi=softfp’],
                    }]
    ]

Start the build again and let it complete:

./util/build-chromium.sh

This step can take several hours depending, of course,  on your build machine.

At this point, Chromium should be built, and you just need to build berkelium library with cmake.

Since allocator, seccomp_sandbox and yuv_convert_sse2 are not compiled for ARM, you’ll have to remove references to those in FindChrome.cmake. You also need to disable all TEST code in CMakeList.txt.

Cross-compile berkelium and install it in a specific directory (e.g. ~/edev/raspberry-pi/libs):

cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/edev/raspberry-pi/libs/
make
make install

If you have problems at the link stage with missing libraries, you may need to modify CMakeFiles/libberkelium.dir/link.txt and add the paths (LDFLAGS) to the libraries.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
4 Comments
oldest
newest
Michel van der Breggen
Michel van der Breggen
11 years ago

Could you publish your version of libbrowsernode for the raspberry so other people can use it?

With regards,
Michel

Michel van der Breggen
Michel van der Breggen
11 years ago

Is it slow or won’t it render or won’t it compile at all?

I am not able to get the toolchain for cross compile.

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...