Home Explore Blog CI



rustc

3rd chunk of `src/backend/updating-llvm.md`
54e7a226aefdcfc81421871517916508af3e0a69d995acce00000001000008a6
   rust-lang/llvm-project branch that rustc is currently using.

1. Build the new LLVM in the `rust` repository.
   To do this,
   you'll want to update the `src/llvm-project` repository to your branch,
   and the revision you've created.
   It's also typically a good idea to update `.gitmodules` with the new
   branch name of the LLVM submodule.
   Make sure you've committed changes to
   `src/llvm-project` to ensure submodule updates aren't reverted.
   Some commands you should execute are:

   * `./x build src/llvm-project` - test that LLVM still builds
   * `./x build` - build the rest of rustc

   You'll likely need to update [`llvm-wrapper/*.cpp`][`llvm-wrapper`]
   to compile with updated LLVM bindings.
   Note that you should use `#ifdef` and such to ensure
   that the bindings still compile on older LLVM versions.

   Note that `profile = "compiler"` and other defaults set by `./x setup`
   download LLVM from CI instead of building it from source.
   You should disable this temporarily to make sure your changes are being used.
   This is done by having the following setting in `bootstrap.toml`:

   ```toml
   [llvm]
   download-ci-llvm = false
   ```

1. Test for regressions across other platforms. LLVM often has at least one bug
   for non-tier-1 architectures, so it's good to do some more testing before
   sending this to bors! If you're low on resources you can send the PR as-is
   now to bors, though, and it'll get tested anyway.

   Ideally, build LLVM and test it on a few platforms:

   * Linux
   * macOS
   * Windows

   Afterwards, run some docker containers that CI also does:

   * `./src/ci/docker/run.sh wasm32`
   * `./src/ci/docker/run.sh arm-android`
   * `./src/ci/docker/run.sh dist-various-1`
   * `./src/ci/docker/run.sh dist-various-2`
   * `./src/ci/docker/run.sh armhf-gnu`

1. Prepare a PR to `rust-lang/rust`. Work with maintainers of
   `rust-lang/llvm-project` to get your commit in a branch of that repository,
   and then you can send a PR to `rust-lang/rust`. You'll change at least
   `src/llvm-project` and will likely also change [`llvm-wrapper`] as well.

   <!-- date-check: mar 2025 -->
   > For prior art, here are some previous LLVM updates:

Title: Building and Testing New LLVM, Preparing the Rust PR
Summary
This section covers the process of building the new LLVM in the Rust repository, including updating the `src/llvm-project` submodule and `.gitmodules`, testing the LLVM build with `./x build`, and updating `llvm-wrapper/*.cpp` to maintain compatibility with older LLVM versions. It also explains how to disable the default behavior of downloading LLVM from CI, and encourages testing for regressions across different platforms and using Docker containers for CI-like testing. Finally, it details preparing a PR to `rust-lang/rust` by coordinating with `rust-lang/llvm-project` maintainers and updating relevant files such as `src/llvm-project` and [`llvm-wrapper`].