Difference between revisions of "Porting/Chromium (New)"

From RCS Wiki
Jump to navigation Jump to search
(Clarify current patch maintenance situation)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Chromium on POWER ==
 
== Chromium on POWER ==
The repository of all required patches for ppc64le is available here: https://github.com/shawnanastasio/chromium_power.
+
The original repository of all required patches for ppc64le [https://github.com/shawnanastasio/chromium_power is available here]. You probably shouldn't use this repo, as it is unmaintained.
  
A source distribution of ungoogled-chromium with the patches incorporated is available here: https://github.com/leo-lb/ungoogled-chromium.
+
A source distribution of ungoogled-chromium with the patches incorporated [https://github.com/leo-lb/ungoogled-chromium is available here]. This one is also unmaintained and should probably not be used.
  
Additional patches required for ppc64 (Big Endian) are available here: [[Porting/Chromium/BE]].
+
Current ppc64le patches (based on the above patches but rebased against current Chromium) are [https://quickbuild.io/~raptor-engineering-public/+archive/ubuntu/chromium/+packages maintained by Raptor Engineering]. To get the patch set, click on the <code>chromium</code> package, and look for the file whose name ends with <code>.debian.tar.xz</code>.
 +
 
 +
[https://salsa.debian.org/chromium-team/chromium/-/tree/master/debian/patches/ppc64le Debian] and [https://github.com/PF4Public/gentoo-overlay/tree/master/www-client/ungoogled-chromium/files/ppc64le Gentoo] further maintain downstream ppc64le patchsets. Debian's patches are mostly the same as Raptor's; Gentoo's patches are to be applied on top of Raptor's.
 +
 
 +
Additional patches required for ppc64 ([[Big-endian]]) are available here: [[Porting/Chromium/BE]].
  
 
The old Chromium wiki page is available here: [[Porting/Chromium_(Old)]].
 
The old Chromium wiki page is available here: [[Porting/Chromium_(Old)]].
Line 51: Line 55:
 
Next is depot_tools, a collection of source code management tools used by Google.
 
Next is depot_tools, a collection of source code management tools used by Google.
 
  <nowiki>
 
  <nowiki>
$ cd $CHROMIUM_DIR
+
$ cd
 
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git </nowiki>
 
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git </nowiki>
  
Line 154: Line 158:
 
If all goes well, you will have a compiled Chromium binary at <code>$CHROMIUM_DIR/chromium/src/out/Default/chrome</code>. If you encounter an error,  
 
If all goes well, you will have a compiled Chromium binary at <code>$CHROMIUM_DIR/chromium/src/out/Default/chrome</code>. If you encounter an error,  
 
[https://github.com/shawnanastasio/chromium_power/issues please report an issue here].
 
[https://github.com/shawnanastasio/chromium_power/issues please report an issue here].
 +
 +
== Binaries ==
 +
 +
Chromium is available in the Debian package repos for <code>ppc64el</code>.
 +
 +
[[Category:Ports]]

Latest revision as of 00:27, 5 May 2023

Chromium on POWER

The original repository of all required patches for ppc64le is available here. You probably shouldn't use this repo, as it is unmaintained.

A source distribution of ungoogled-chromium with the patches incorporated is available here. This one is also unmaintained and should probably not be used.

Current ppc64le patches (based on the above patches but rebased against current Chromium) are maintained by Raptor Engineering. To get the patch set, click on the chromium package, and look for the file whose name ends with .debian.tar.xz.

Debian and Gentoo further maintain downstream ppc64le patchsets. Debian's patches are mostly the same as Raptor's; Gentoo's patches are to be applied on top of Raptor's.

Additional patches required for ppc64 (Big-endian) are available here: Porting/Chromium/BE.

The old Chromium wiki page is available here: Porting/Chromium_(Old).

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-build 

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
$ git checkout 81ee1967d3fcbc829bac1c005c3da59739c88df9 # Latest GN is broken with chromium...
$ python build/gen.py
$ 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
$ 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_SVN_REVISION=357692 # Check the above link for the current version
$ svn checkout --force https://llvm.org/svn/llvm-project/llvm/trunk@$CLANG_SVN_REVISION llvm
$ svn checkout --force https://llvm.org/svn/llvm-project/cfe/trunk@$CLANG_SVN_REVISION llvm/tools/clang
$ svn checkout --force https://llvm.org/svn/llvm-project/compiler-rt/trunk@$CLANG_SVN_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 

To finish the source code checkout, we need to apply a single patch, disable NaCL, and replace the included GN binary with our own.

$ cd src
$ curl 'https://raw.githubusercontent.com/shawnanastasio/chromium_power/master/build_toolchain/Binutils-download.py-PPC.patch' | patch -p1
$ cp -f $CHROMIUM_DIR/gn/out/gn buildtools/linux64/gn
$ cd ..
$ sed -i 's/\"custom_vars\"\: {},/\"custom_vars\"\: { \"checkout_nacl\"\: False },/g' .gclient
$ gclient sync 

Patching Chromium

The patches required to build Chromium are maintained here. Included is a script which will apply all the patches to a Chromium source directory. To patch your local copy of the Chromium source, do the following:

$ cd $CHROMIUM_DIR
$ git clone https://github.com/shawnanastasio/chromium_power
$ cd chromium_power
$ python3 cpf.py $CHROMIUM_DIR/chromium/src 

This will attempt to apply all the patches. If an error is encountered, you can attempt to rebase the patch manually by following the prompts, or you can create a GitHub issue to notify the maintainers. Note that any errors about already applied patches can be safely ignored.

Pre-build

Now Chromium is almost ready to be built. First though, the ppc64le build files for ffmpeg and libvpx will need to be generated.

$ cd $CHROMIUM_DIR/chromium/src/third_party/ffmpeg
$ ./chromium/scripts/build_ffmpeg.py linux ppc64
$ ./chromium/scripts/generate_gn.py
$ ./chromium/scripts/copy_config.sh

$ cd ../libvpx
$ mkdir source/config/linux/ppc64
$ ./generate_gni.sh
$ cd ../../ 

Build

Now you're ready to build Chromium. First, the build parameters must be configured with gn. To do this, perform the following:

$ cd $CHROMIUM_DIR/chromium/src
$ gn args out/Default 

A text editor will open. Paste in the following configuration, modified to suit your needs if necessary:

# Release mode
is_component_build = false
is_debug = false

# Disable broken features
enable_nacl = false
treat_warnings_as_errors = false
enable_dav1d_decoder = false

# For clang, add the following lines:
is_clang = true
clang_base_path = "$CHROMIUM_DIR/llvm_build"
clang_use_chrome_plugins = false
use_lld = false 

Note that clang_base_path will have to be modified to contain the full path to your $CHROMIUM_DIR/llvm_build directory that was created earlier.

Close and save the text file and perform the following to build Chromium:

$ ninja -C out/Default chrome 

This will perform a parallel build of Chromium using all available threads. To limit the number of threads, append -jX where X is the number of threads you wish to use. If all goes well, you will have a compiled Chromium binary at $CHROMIUM_DIR/chromium/src/out/Default/chrome. If you encounter an error, please report an issue here.

Binaries

Chromium is available in the Debian package repos for ppc64el.