Porting/Chromium (New)

From RCS Wiki
Revision as of 19:39, 28 April 2019 by Shawnanastasio (talk | contribs) (First partial draft of new chromium page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Chromium on POWER

Introduction

Google's Chromium browser has been ported by the community to run on POWER systems. The base patch set targets CPUs running in Little Endian mode (ppc64le), but additional patches for Big Endian support exist as well.

There is an ongoing effort to get the patches upstreamed, but at the moment it is still required to apply some out-of-tree patches to get the browser to build. This page documents how to download and build Chromium for ppc64le.

Prerequisites

To build chromium, you'll need a ppc64le Linux environment with around 70GB of free disk space and at least 8GB of RAM. For parallel builds (recommended), the amount of RAM required will scale with the number of cores in your machine. Approximately 1GB per SMT thread seems to be reasonable.

Before beginning, you will need to install Chromium's dependencies from your distribution's package manager. For Ubuntu, the following should be sufficient:

# apt install git vim cmake python libcups2-dev pkg-config libnss3-dev libssl-dev libglib2.0-dev libgnome-keyring-dev libpango1.0-dev libdbus-1-dev libatk1.0-dev libatk-bridge2.0-dev libgtk-3-dev libkrb5-dev libpulse-dev libxss-dev re2c subversion curl libasound2-dev libpci-dev mesa-common-dev gperf bison nodejs uuid-dev clang-format ninja 

Next, you'll need some utilities that most likely aren't available in your distribution's repositories.

It is recommended to complete these steps in a new directory reserved for chromium and its dependencies, like ~/chromium_build. This directory will henceforth be referred to as $CHROMIUM_DIR.

GN

First is gn, the meta-build system:

$ cd $CHROMIUM_DIR
$ git clone https://gn.googlesource.com/gn

$ export CC=gcc
$ export CXX=g++
$ export AR=ar

$ cd gn
$ python build/gen.py --no-sysroot
$ cat out/build.ninja | sed s/-stdlib=libstdc++//g | tee out/build.ninja
$ ninja -C out

$ unset CXX
$ unset CC
$ unset AR 

depot_tools

Next is depot_tools, a collection of source code management tools used by Google.

$ cd $CHROMIUM_DIR
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git 

In order to use the tools, they'll need to be in your path. It is recommended to place the following lines in a file named env.sh that you source, or in your .bashrc:

$ cd $CHROMIUM_DIR
$ echo 'export PATH="$PATH:${HOME}/ninja"' >> env.sh
$ echo 'export PATH="$PATH:${HOME}/depot_tools"' >> env.sh
$ echo 'export VPYTHON_BYPASS="manually managed python not supported by chrome operations"' >> env.sh
$ source env.sh 

LLVM/Clang

Chromium is only tested against specific revisions of the Clang compiler. As such, it is highly recommended to compile the specific version Chromium expects manually. The current version expected by Chromium may always be found here.

First, we must check out LLVM and Clang:

$ cd $CHROMIUM_DIR
$ export CLANG_REVISION=357692 # Check the above link for the current version
$ svn checkout --force https://llvm.org/svn/llvm-project/llvm/trunk@$CLANG_REVISION llvm
$ svn checkout --force https://llvm.org/svn/llvm-project/cfe/trunk@$CLANG_REVISION llvm/tools/clang
$ svn checkout --force https://llvm.org/svn/llvm-project/compiler-rt/trunk@$CLANG_REVISION llvm/compiler-rt 

Next, we'll create a build directory and build the compiler.

$ mkdir llvm_build && cd llvm_build
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="PowerPC" -G "Unix Makefiles" ../llvm
$ make -j64 # Replace with # of threads to compile with 

Downloading the source code

After completing the prerequisite steps, you can download the Chromium source code. Make sure that `depot_tools` is in your PATH by sourcing your env.sh and run the following:

$ cd $CHROMIUM_DIR
$ mkdir chromium && cd chromium
$ fetch --no-history --nohooks chromium 

Patching Chromium