blob: 08ac1dbf9d4b74479e43701ee46657739ee5c15f [file] [log] [blame] [view]
Tom Andersona46d23e2019-12-19 19:27:571# Linux Instrumented Libraries
2
3The instrumented libraries are a collection of Chromium's dependencies built
4with *SAN enabled. The MSAN libraries are required for an MSAN build to run. The
5others are optional, and are currently unused.
6
7## Building the instrumented libraries
8
9### Setting up a chroot
10
11Building the libraries requires `apt-get source`, so the build must be done from
Tom Andersonfe9ef132023-02-01 23:42:4012an Ubuntu 20.04 environment. The preferred way is using a chroot. To get
Tom Andersona46d23e2019-12-19 19:27:5713started, install `debootstrap` and `schroot`. If you're running a Debian-based
14distro, run:
15
16```shell
17sudo apt install debootstrap schroot
18```
19
Tom Andersonfe9ef132023-02-01 23:42:4020Create a configuration for a Focal chroot:
Tom Andersona46d23e2019-12-19 19:27:5721
22```shell
Tom Andersonfe9ef132023-02-01 23:42:4023sudo $EDITOR /etc/schroot/chroot.d/focal_amd64.conf
Tom Andersona46d23e2019-12-19 19:27:5724```
25
26Add the following to the new file, replacing the instances of `thomasanderson`
27with your own username.
28
29```
Tom Andersonfe9ef132023-02-01 23:42:4030[focal_amd64]
31description=Ubuntu 20.04 Focal for amd64
32directory=/srv/chroot/focal_amd64
Tom Andersona46d23e2019-12-19 19:27:5733personality=linux
34root-users=thomasanderson
35type=directory
36users=thomasanderson
37```
38
39Bootstrap the chroot:
40
41```shell
Tom Andersonfe9ef132023-02-01 23:42:4042sudo mkdir -p /srv/chroot/focal_amd64
43sudo debootstrap --variant=buildd --arch=amd64 focal /srv/chroot/focal_amd64 http://archive.ubuntu.com/ubuntu/
Tom Andersona46d23e2019-12-19 19:27:5744```
45
46If your `$HOME` directory is not `/home` (as is the case on gLinux), then route
47`/home` to the real thing. `schroot` automatically mounts `/home`, which is
48where I'm assuming you keep your source tree and `depot_tools`.
49
50```shell
51sudo mount --bind "$HOME" /home
52```
53
54Add `sources.list`:
55
56```shell
Tom Andersonfe9ef132023-02-01 23:42:4057sudo $EDITOR /srv/chroot/focal_amd64/etc/apt/sources.list
Tom Andersona46d23e2019-12-19 19:27:5758```
59
60Add the following contents to the file:
61
62```
Tom Andersonfe9ef132023-02-01 23:42:4063deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe
64deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe
65deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe
66deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe
67deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe
68deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe
Tom Andersona46d23e2019-12-19 19:27:5769```
70
71Enter the chroot and install the necessary packages:
72
73```shell
Tom Andersonfe9ef132023-02-01 23:42:4074schroot -c focal_amd64 -u root --directory /home/dev/chromium/src
Tom Andersona46d23e2019-12-19 19:27:5775apt update
76apt install lsb-release sudo python pkg-config libgtk2.0-bin libdrm-dev nih-dbus-tool help2man
77```
78
Tom Andersona46d23e2019-12-19 19:27:5779Install library packages:
80
81```shell
82third_party/instrumented_libraries/scripts/install-build-deps.sh
83```
84
Tom Andersonb7136952021-10-07 00:48:1985Change to a non-root user:
86```shell
87exit
Tom Andersonfe9ef132023-02-01 23:42:4088schroot -c focal_amd64 -u `whoami` --directory /home/dev/chromium/src
Tom Andersonb7136952021-10-07 00:48:1989```
90
91Add `depot_tools` to your `PATH`. For example, I have it in `~/dev/depot_tools`,
92so I use:
93
94```shell
95export PATH=/home/dev/depot_tools/:$PATH
96```
97
Tom Andersona46d23e2019-12-19 19:27:5798Now we're ready to build the libraries. A clean build takes a little over 8
99minutes on a 72-thread machine.
100
101```shell
Tom Andersonfe9ef132023-02-01 23:42:40102third_party/instrumented_libraries/scripts/build_and_package.py --parallel -j $(nproc) all focal
Tom Andersona46d23e2019-12-19 19:27:57103```
104
105## Uploading the libraries
106
107This requires write permission on the `chromium-instrumented-libraries` GCS
108bucket. `dpranke@` can grant access.
109
110```shell
111# Exit the chroot.
112exit
113
Tom Andersona46d23e2019-12-19 19:27:57114# Move files into place.
115mv *.tgz third_party/instrumented_libraries/binaries
116
117# Upload.
Tom Anderson9f5ce7572021-10-15 21:55:43118upload_to_google_storage.py -b chromium-instrumented-libraries third_party/instrumented_libraries/binaries/msan*.tgz
Tom Andersona46d23e2019-12-19 19:27:57119```
120
121## Testing and uploading a CL
122
123After uploading, run `gclient sync` and test out a build with `is_msan = true`
124in your `args.gn`. Try running eg. `chrome` and `unit_tests` to make sure it's
125working. The binaries should work natively on gLinux.
126
127When uploading a CL, make sure to add the following in the description so that
128the MSAN bot will run on the CQ:
129
130```
131CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux_chromium_msan_rel_ng
132```