Move to clang 21 as mininum version and use it in CI (#7779)

Clang 21 is now the latest version available in Ubuntu LTS, so we can
move to it.
This commit is contained in:
Dana Jansens
2026-09-11 16:58:59 +00:00
committed by GitHub
parent 7d70f72bec
commit c45efd625f
5 changed files with 26 additions and 30 deletions
+14 -14
View File
@@ -49,8 +49,8 @@ These commands should help set up a development environment on your machine.
# Update apt.
sudo apt update
# Check that the `clang` version is at least 19, our minimum version. That needs
# the number of the `:` in the output to be over 19. For example, `1:19.0-1`.
# Check that the `clang` version is at least 21, our minimum version. That needs
# the number of the `:` in the output to be over 21. For example, `1:21.0-1`.
apt-cache show clang | grep 'Version:'
# Install tools. Use the same version as the Clang version you found above. Do
@@ -88,28 +88,28 @@ it to your `$PATH`, and aliasing `bazel` to it.
#### Old `clang` versions
If the version of `clang` is earlier than 19, you may still have version 19
If the version of `clang` is earlier than 21, you may still have version 21
available. You can use the following install instead:
```shell
# Install explicitly versioned Clang tools.
sudo apt install \
clang-19 \
libc++-19-dev \
libc++abi-19-dev \
lld-19 \
lldb-19
clang-21 \
libc++-21-dev \
libc++abi-21-dev \
lld-21 \
lldb-21
# In your Carbon checkout, tell Bazel where to find `clang`. You can also
# export this path as the `CC` environment variable, or add it directly to
# your `PATH`.
echo "build --repo_env=CC=$(readlink -f $(which clang-19))" >> user.bazelrc
echo "build --repo_env=CC=$(readlink -f $(which clang-21))" >> user.bazelrc
```
And if it's not available directly from the distribution, you can install Clang
tools on Debian/Ubuntu from <https://apt.llvm.org>.
> NOTE: Most LLVM 19+ installs should build Carbon. If you're having issues, see
> NOTE: Most LLVM 21+ installs should build Carbon. If you're having issues, see
> [troubleshooting build issues](#troubleshooting-build-issues).
### macOS
@@ -203,7 +203,7 @@ These tools are essential for work on Carbon.
- [Bazelisk](https://docs.bazel.build/versions/master/install-bazelisk.html):
Downloads and runs the [configured Bazel version](/.bazelversion).
- [Clang](https://clang.llvm.org/) and [LLVM](https://llvm.org/)
- NOTE: Most LLVM 19+ installs should build Carbon. If you're having
- NOTE: Most LLVM 21+ installs should build Carbon. If you're having
issues, see
[troubleshooting build issues](#troubleshooting-build-issues).
- [gh CLI](https://github.com/cli/cli): Helps with GitHub.
@@ -419,8 +419,8 @@ includes things such as changing LLVM versions, or installing libc++. Running
Many build issues result from the particular options `clang` and `llvm` have
been built with, particularly when it comes to system-installed versions. If you
run `clang --version`, you should see at least version 19. If you see an older
version, please update, or use the special `clang-19` instructions above.
run `clang --version`, you should see at least version 21. If you see an older
version, please update, or use the special `clang-21` instructions above.
System installs of macOS typically won't work, for example being an old LLVM
version or missing llvm-ar; [setup commands](#setup-commands) includes LLVM from
@@ -442,7 +442,7 @@ providing the output of the following diagnostic commands:
```shell
echo $CC
which clang
which clang-19
which clang-21
clang --version
grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/+clang_toolchain_extension+bazel_cc_toolchain/clang_detected_variables.bzl