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