Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 1 | Configurations supported by the toolchain team |
| 2 | ============================================== |
| 3 | |
Peter Kasting | beb265c | 2024-10-31 20:22:56 | [diff] [blame] | 4 | This document describes the existing supported build configs, and considerations |
| 5 | to 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 Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 8 | |
Peter Kasting | beb265c | 2024-10-31 20:22:56 | [diff] [blame] | 9 | Existing toolchain support |
| 10 | -------------------------- |
| 11 | |
| 12 | Chromium prioritizes user benefits (safety, performance) and maintainability |
| 13 | over theoretical purity (e.g. standards compliance for its own sake). Currently, |
| 14 | the best way to achieve those goals is to support a single compiler (`clang`) |
| 15 | and 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 | |
| 22 | Even within clang/libc++, we often rely on recent bugfixes and feature |
| 23 | additions, so generally only the most recent LLVM version is supported. Building |
| 24 | Chromium with an unsupported toolchain will fail to compile at best; at worst, |
| 25 | it will compile, but have bugs, security holes, or reduced performance. |
| 26 | |
| 27 | We currently allow community-contributed patches that support building with gcc, |
| 28 | since this is a requirement for many Linux environments and can be accommodated |
| 29 | without much maintainability cost or risk of introducing unsafe behavior. As of |
| 30 | M138, however, even gcc builds will only work with libc++. |
| 31 | |
| 32 | Toolchain updates |
| 33 | ----------------- |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 34 | |
| 35 | We update our toolchain (the C/C++/Objective-C compiler `clang`, the linker |
Peter Kasting | beb265c | 2024-10-31 20:22:56 | [diff] [blame] | 36 | `lld`, the STL implementation `libc++`, and a small assortment of helper |
| 37 | binaries) every 2-4 weeks. |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 38 | |
| 39 | This toolchain is used to build Chromium for **7+ platforms** (Android, |
| 40 | Chromecast, Chrome OS, Fuchsia, iOS, Linux, macOS, Windows) targeting |
| 41 | **4+ CPUs** (arm, arm64, x86, x64) in **6+ build modes** (debug (component |
| 42 | non-optimized), release (static build optimized), official build (very |
| 43 | optimized and on some platforms LTO+CFI), asan+lsan, msan, tsan), resulting |
| 44 | in **130+** different test binaries. |
| 45 | |
| 46 | Every toolchain update needs to make sure that none of these combinations break. |
| 47 | |
| 48 | To have any chance that this works, we continuously build and run tests in |
| 49 | most of these configurations with trunk clang/llvm, to catch regressions and |
Andrew Williams | e223ab9 | 2021-07-16 23:40:27 | [diff] [blame] | 50 | intentional changes upstream that cause problems for us. |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 51 | |
| 52 | When we land a toolchain update, we rely on the CQ to make sure all combinations |
| 53 | work with the new toolchain. We use all default CQ bots, and a long list of |
| 54 | opt-in trybots. |
| 55 | |
| 56 | The toolchain team has established contacts to most platform owners in |
| 57 | Chromium, so that we can ask for help quickly when needed. |
| 58 | |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 59 | Toolchain guarantees |
| 60 | -------------------- |
| 61 | |
| 62 | For configurations that have a bot on the [chromium.clang waterfall]( |
| 63 | https://ci.chromium.org/p/chromium/g/chromium.clang/console) (which |
| 64 | is where all the bots are that test Chromium with trunk clang/llvm) |
| 65 | and that are either part of the default CQ or that have an opt-in bot |
| 66 | that'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), |
| 67 | we guarantee that we won't land a toolchain update that breaks that |
| 68 | configuration. |
| 69 | |
| 70 | For configurations that don't have a clang tip-of-tree (ToT) bot or that aren't |
| 71 | covered on the CQ, **we won't revert toolchain updates**. We will do our best |
| 72 | to fix things quickly (see below for how to file a good bug) and to fix forward |
| 73 | to get you unblocked. |
| 74 | |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 75 | Talk to the toolchain team to make sure your new config is supported |
| 76 | -------------------------------------------------------------------- |
| 77 | |
| 78 | If you add a new build config, or a new bot config: You may want to add a |
| 79 | chromium.clang ToT bot, and you may want to make sure that there's a CQ bot |
| 80 | covering your config on clang rolls. (It's ok if it's an opt-in bot, as long as |
| 81 | you 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) |
| 83 | for clang rolls. If your opt-in is based on filename patterns, make sure it |
| 84 | also fires on changes to `tools/clang/scrips/update.py`.) |
| 85 | |
| 86 | Do not use `-mllvm` or `-Xclang` flags. These are internal flags that aren't |
| 87 | ready for production use yet. Once they're ready, they'll become available |
| 88 | as regular clang flags. |
| 89 | |
| 90 | Follow the style guide. In particular, don't use exceptions. |
| 91 | |
| 92 | Talk to us if you're adding a new build config or bot config, if you'd like to |
| 93 | use an internal flag, if you want to use a flag that's obscure, or if you want |
| 94 | general advice on toolchain questions (clang@chromium.org, or |
| 95 | google-internally, lexan@google.com). |
| 96 | |
| 97 | Filing good toolchain bugs |
| 98 | -------------------------- |
| 99 | |
| 100 | If a toolchain update ("clang roll") broke you, here's how you can file a bug |
| 101 | that 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 Bonadei | f7309de | 2020-02-17 18:54:44 | [diff] [blame] | 112 | - Tell us which repo to check out, if needed. |
Nico Weber | 1683eec9 | 2020-02-14 12:31:00 | [diff] [blame] | 113 | - Tell us which `args.gn` to use. |
| 114 | - Tell us which target to build. |
| 115 | - Tell us how to run your test. |
| 116 | |
| 117 | We'll try to be helpful, but see "Toolchain guarantees" above. |
| 118 | |
| 119 | Compiler updates can expose latent existing bugs in your code, for example |
| 120 | if you have ODR violations, or other undefined behavior. In that case, |
| 121 | the fix is to change your code. It can be helpful to make a reduced repro |
| 122 | case of the problem before looping us in, so that you can check if your problem |
| 123 | is really due to the toolchain update and not due to a bug in your code. |