blob: 3f395fc537ad53a18c94890198621ee7d3116437 [file] [log] [blame] [view]
Nico Weber1683eec92020-02-14 12:31:001Configurations supported by the toolchain team
2==============================================
3
Peter Kastingbeb265c2024-10-31 20:22:564This document describes the existing supported build configs, and considerations
5to follow when adding a new one. A build config is something like a new compiler
6/ linker configuration, a new test binary, a new `target_os`, a new
7`target_cpu`, etc.
Nico Weber1683eec92020-02-14 12:31:008
Peter Kastingbeb265c2024-10-31 20:22:569Existing toolchain support
10--------------------------
11
12Chromium prioritizes user benefits (safety, performance) and maintainability
13over theoretical purity (e.g. standards compliance for its own sake). Currently,
14the best way to achieve those goals is to support a single compiler (`clang`)
15and STL implementation (`libc++`).
16* We use clang-specific extensions (e.g. the
17 `[[clang::lifetimebound]]` C++ attribute)
18* We rely on guarantees in libc++ beyond what the STL requires (e.g.
19 deterministically crashing for certain cases of UB; having a
20 trivially-relocatable `std::string` implementation)
21
22Even within clang/libc++, we often rely on recent bugfixes and feature
23additions, so generally only the most recent LLVM version is supported. Building
24Chromium with an unsupported toolchain will fail to compile at best; at worst,
25it will compile, but have bugs, security holes, or reduced performance.
26
27We currently allow community-contributed patches that support building with gcc,
28since this is a requirement for many Linux environments and can be accommodated
29without much maintainability cost or risk of introducing unsafe behavior. As of
30M138, however, even gcc builds will only work with libc++.
31
32Toolchain updates
33-----------------
Nico Weber1683eec92020-02-14 12:31:0034
35We update our toolchain (the C/C++/Objective-C compiler `clang`, the linker
Peter Kastingbeb265c2024-10-31 20:22:5636`lld`, the STL implementation `libc++`, and a small assortment of helper
37binaries) every 2-4 weeks.
Nico Weber1683eec92020-02-14 12:31:0038
39This toolchain is used to build Chromium for **7+ platforms** (Android,
40Chromecast, Chrome OS, Fuchsia, iOS, Linux, macOS, Windows) targeting
41**4+ CPUs** (arm, arm64, x86, x64) in **6+ build modes** (debug (component
42non-optimized), release (static build optimized), official build (very
43optimized and on some platforms LTO+CFI), asan+lsan, msan, tsan), resulting
44in **130+** different test binaries.
45
46Every toolchain update needs to make sure that none of these combinations break.
47
48To have any chance that this works, we continuously build and run tests in
49most of these configurations with trunk clang/llvm, to catch regressions and
Andrew Williamse223ab92021-07-16 23:40:2750intentional changes upstream that cause problems for us.
Nico Weber1683eec92020-02-14 12:31:0051
52When we land a toolchain update, we rely on the CQ to make sure all combinations
53work with the new toolchain. We use all default CQ bots, and a long list of
54opt-in trybots.
55
56The toolchain team has established contacts to most platform owners in
57Chromium, so that we can ask for help quickly when needed.
58
Nico Weber1683eec92020-02-14 12:31:0059Toolchain guarantees
60--------------------
61
62For configurations that have a bot on the [chromium.clang waterfall](
63https://ci.chromium.org/p/chromium/g/chromium.clang/console) (which
64is where all the bots are that test Chromium with trunk clang/llvm)
65and that are either part of the default CQ or that have an opt-in bot
66that's [used on clang rolls](https://cs.chromium.org/chromium/src/tools/clang/scripts/upload_revision.py?q=upload_revi&sq=package:chromium&g=0&l=33),
67we guarantee that we won't land a toolchain update that breaks that
68configuration.
69
70For configurations that don't have a clang tip-of-tree (ToT) bot or that aren't
71covered on the CQ, **we won't revert toolchain updates**. We will do our best
72to fix things quickly (see below for how to file a good bug) and to fix forward
73to get you unblocked.
74
Nico Weber1683eec92020-02-14 12:31:0075Talk to the toolchain team to make sure your new config is supported
76--------------------------------------------------------------------
77
78If you add a new build config, or a new bot config: You may want to add a
79chromium.clang ToT bot, and you may want to make sure that there's a CQ bot
80covering your config on clang rolls. (It's ok if it's an opt-in bot, as long as
81you make sure it's
82[opted-in](https://cs.chromium.org/chromium/src/tools/clang/scripts/upload_revision.py?q=upload_revi&sq=package:chromium&g=0&l=33)
83for clang rolls. If your opt-in is based on filename patterns, make sure it
84also fires on changes to `tools/clang/scrips/update.py`.)
85
86Do not use `-mllvm` or `-Xclang` flags. These are internal flags that aren't
87ready for production use yet. Once they're ready, they'll become available
88as regular clang flags.
89
90Follow the style guide. In particular, don't use exceptions.
91
92Talk to us if you're adding a new build config or bot config, if you'd like to
93use an internal flag, if you want to use a flag that's obscure, or if you want
94general advice on toolchain questions (clang@chromium.org, or
95google-internally, lexan@google.com).
96
97Filing good toolchain bugs
98--------------------------
99
100If a toolchain update ("clang roll") broke you, here's how you can file a bug
101that we can act on the quickest:
102
103- File the bug in the `Tools>LLVM` component.
104- Link to the CL with the toolchain update that broke you.
105- Link to a specific build showing the breakage, ideally the first instance
106 of the breakage.
107- If reproducing your problem requires more than a regular Chromium checkout
108 and replicating what the bot you linked to does, or if you can't link to a
109 build: Provide commands on how to reproduce your problem, targeted at someone
110 who knows the chromium build well but doesn't know your feature / platform
111 at all.
Mirko Bonadeif7309de2020-02-17 18:54:44112 - Tell us which repo to check out, if needed.
Nico Weber1683eec92020-02-14 12:31:00113 - Tell us which `args.gn` to use.
114 - Tell us which target to build.
115 - Tell us how to run your test.
116
117We'll try to be helpful, but see "Toolchain guarantees" above.
118
119Compiler updates can expose latent existing bugs in your code, for example
120if you have ODR violations, or other undefined behavior. In that case,
121the fix is to change your code. It can be helpful to make a reduced repro
122case of the problem before looping us in, so that you can check if your problem
123is really due to the toolchain update and not due to a bug in your code.