Ozone is Chromium’s next-gen platform abstraction layer for graphics and input. When developing either Ozone itself or an application that uses Ozone, it is often beneficial to be able to run the code on the development machine, which is usually a typical GNU/Linux desktop system, since doing so speeds up the development cycle.
By Alexandros Frantzis, Senior Software Engineer at Collabora.
The X11 backend for Ozone works without much trouble on a Linux desktop system. However, getting the DRM/GBM backend to run on such a system, which I recently needed to do as part of my work at Collabora, turned out to be significantly less straightforward. In this guide I will describe all the steps that are required to run Chromium with Ozone-GBM on a typical GNU/Linux desktop system.
Building Chromium
The Chromium developer documentation provides detailed build instructions for Linux. For this guide, we have to ensure that we enable Ozone and that the target OS for the build is “chromeos”:
$ gn gen out/OzoneChromeOS $ gn args --args='use_ozone=true target_os="chromeos"' out/OzoneChromeOS $ ninja -C out/OzoneChromeOS chrome
Building a functional minigbm
Ozone-GBM uses the GBM API to create buffers. However, it doesn’t use Mesa’s GBM implementation, but ships its own in the form of the minigbm library. The Chromium source code contains a copy of the library under third_party, but uses it only for building and testing purposes without enabling any of the minigbm hardware drivers.
In order to run Ozone-GBM on real hardware we need to create a build of minigbm that supports our target GPU. For the purposes of this guide, the simplest way to provide a functional minigbm is to build it independently and provide it at runtime to Chromium using LD_LIBRARY_PATH.
First we need to get the minigbm source code with:
$ git clone https://chromium.googlesource.com/chromiumos/platform/minigbm
minigbm depends on libdrm, so we have to ensure that we have the development files for the libdrm library and the vendor specific extensions. On a Debian/Ubuntu system we can get everything we need by installing the libdrm-dev package:
$ sudo apt install libdrm-dev
We can now build minigbm with the correct flags to ensure the proper GPU driver is supported:
$ make CPPFLAGS="-DDRV_I915" DRV_I915=1
Note that we need to provide the driver flag both as a preprocessor definition and a Make variable. Other driver flags for common desktop GPUs are DRV_RADEON and DRV_AMDGPU (but see below for amdgpu).
Finally we need to create a link with the proper file name so that chrome can find the library:
$ ln -s libminigbm.so.1.0.0 libminigbm.so