blob: 1d5eefde7f8db7675c4bf1172d640a3a08bcc465 [file] [log] [blame] [view]
andybons3322f762015-08-24 21:37:091# Updating clang
2
Nico Weber4071eca2018-09-25 12:29:143We distribute prebuilt packages of LLVM binaries, including clang and lld, that
4all developers and bots pull at `gclient runhooks` time. These binaries are
5just regular LLVM binaries built at a fixed upstream revision. This document
6describes how to build a package at a newer revision and update Chromium to it.
7An archive of all packages built so far is at https://is.gd/chromeclang
8
Nico Weberf218afd2018-09-20 19:11:2191. Check that https://ci.chromium.org/p/chromium/g/chromium.clang/console
Arthur Eubanksa8722a52020-08-25 17:15:1210 looks reasonably green. Red bots with seemingly normal test failures are
11 usually ok, that likely means the test is broken with the stable Clang as
12 well.
nodir06cbaa02015-08-25 17:15:24131. Sync your Chromium tree to the latest revision to pick up any plugin
Arthur Eubanksf055cc52020-06-10 02:21:3714 changes.
Hans Wennborgfbda6212025-04-04 14:30:44151. Run
16 [go/chrome-promote-clang](https://goto.google.com/chrome-promote-clang),
17 passing in the revision of the Clang and Rust package version you want to
18 push. For example:
19
20 ```
21 $ copy_staging_to_prod_and_goma.sh --clang-rev llvmorg-21-init-5118-g52cd27e6-1 --rust-rev f7b43542838f0a4a6cfdb17fbeadf45002042a77-1
22 ```
23
24 Alternatively, use
25 [go/chrome-push-clang-to-goma](https://goto.google.com/chrome-push-clang-to-goma).
Nico Weber98926b022020-06-28 11:27:3626 This takes a recent dry run CL to update clang, and if the trybots were
27 successful it will copy the binaries from the staging bucket to the
Hans Wennborgfbda6212025-04-04 14:30:4428 production one.
29
30 Writing to the production bucket requires special permissions.
31 Then it will push the packages to RBE. If you
Nico Weber98926b022020-06-28 11:27:3632 do not have the necessary credentials to do the upload, ask
Arthur Eubanksf055cc52020-06-10 02:21:3733 clang@chromium.org to find someone who does.
Arthur Eubanksa8722a52020-08-25 17:15:1234 * Alternatively, to create your own roll CL, you can manually run
35 `tools/clang/scripts/upload_revision.py` with a recent upstream LLVM
Hans Wennborgfbda6212025-04-04 14:30:4436 commit hash as the argument. After the `*_upload_clang` and `*_upload_rust`
37 trybots are successfully finished, run
Arthur Eubanksa8722a52020-08-25 17:15:1238 [go/chrome-promote-clang](https://goto.google.com/chrome-promote-clang)
Hans Wennborgfbda6212025-04-04 14:30:4439 with the new Clang and Rust package names.
Josip Sokcevica41c3c452024-05-30 15:25:38401. Run `tools/clang/scripts/sync_deps.py` to update the deps entries in DEPS.
Hans Wennborgfbda6212025-04-04 14:30:44411. `gclient sync` to download those packages.
421. Run `tools/rust/gnrt_stdlib.py` to update the GN files for the Rust standard library.
Nico Weber916702902020-01-30 19:25:47431. Run an exhaustive set of try jobs to test the new compiler. The CL
Arthur Eubanksf055cc52020-06-10 02:21:3744 description created previously by upload_revision.py includes
45 `Cq-Include-Trybots:` lines for all needed bots, so it's sufficient to just
46 run `git cl try` (or hit "CQ DRY RUN" on gerrit).
471. Commit the roll CL from the previous step.
Takuto Ikuta7478af722024-05-27 07:23:19481. The bots will now pull the prebuilt binary, and RBE will have a matching
nodir06cbaa02015-08-25 17:15:2449 binary, too.
Nico Weber4071eca2018-09-25 12:29:1450
Arthur Eubanks637eab42020-06-15 18:03:0751## Performance regressions
52
53After doing a clang roll, you may get a performance bug assigned to you
54([example](https://crbug.com/1094671)). Some performance noise is expected
55while doing a clang roll.
56
57You can check all performance data for a clang roll via
58`https://chromeperf.appspot.com/group_report?rev=XXXXXX`, where `XXXXXX` is the
Hans Wennborgfbda6212025-04-04 14:30:4459Chromium revision number, e.g. `778090` for the example bug (look in the first
60message of the performance bug to find this). Click the checkboxes to display
61graphs. Hover over points in the graph to see the value and error.
Arthur Eubanks637eab42020-06-15 18:03:0762
63Serious regressions require bisecting upstream commits (TODO: how to repro?).
64If the regressions look insignificant and there is green as well as red, you
65can close the bug as "WontFix" with an explanation.
66
Nico Weber4071eca2018-09-25 12:29:1467## Adding files to the clang package
68
69The clang package is downloaded unconditionally by all bots and devs. It's
70called "clang" for historical reasons, but nowadays also contains other
71mission-critical toolchain pieces besides clang.
72
73We try to limit the contents of the clang package. They should meet these
74criteria:
75
76- things that are used by most developers use most of the time (e.g. a
77 compiler, a linker, sanitizer runtimes)
78- things needed for doing official builds
79
Andrew Grieve2989fb82024-04-22 14:42:3680# Adding a New Package
Nico Weber4071eca2018-09-25 12:29:1481
Andrew Grieve2989fb82024-04-22 14:42:3682If you want to make artifacts available that do not meet the criteria for
83being included in the "clang" package, you can make package.py upload it to
84a separate zip file and then download it on an opt-in basis by using
85update.py's --package option. Here is [an example of adding a new package].
86
87To test changes to `package.py`, change `CLANG_SUB_REVISION` in `update.py` to
88a random number above 2000 and run the `*_upload_clang` trybots.
89
90Once the change to `package.py` is in, file a bug under `Tools > LLVM`
91requesting that a new package be created ([example bug]).
92
93Once it's been uploaded and rolled, you can download it via:
94
95```
96tools/clang/scripts/update.py --package your-package-name
97```
98
99[an example of adding a new package](https://chromium-review.googlesource.com/c/chromium/src/+/5463029)
Takuto Ikuta7478af722024-05-27 07:23:19100[example bug]: https://crbug.com/335730441
Hans Wennborg0499381b2025-04-07 11:13:59101
102# On local patches and cherry-picks
103
104Except for the addition of Clang plugins, which do not affect the compiler
105output, Chromium's LLVM binaries are vanilla builds of the upstream source code
106at a specific revision, with no alterations.
107
108We believe this helps when working with upstream: our compiler should behave
109exactly the same as if someone else built LLVM at the same revision, making
110collaboration easier.
111
112It also creates an incentive for stabilizing the HEAD revision of LLVM: since
113we ship a vanilla build of an upstream revision, we have to ensure that a
114revision can be found which is stable enough to build Chromium and pass all its
115tests. While allowing local cherry-picks, reverts, or other patches, would
116probably allow more regular toolchain releases, we believe we can perform
117toolchain testing and fix issues fast enough that finding a stable revision is
118possible, and that this is the right trade-off for us and for the LLVM
119community.
120
121For Rust, since the interface between tip-of-tree rustc and LLVM is less
122stable, and since landing fixes in Rust is much slower (even after approval, a
123patch can take more than 24 hours to land), we allow cherry-picks of such fixes
124in our Rust toolchain build.