diff --git a/.github/actions/build-setup-common/action.yml b/.github/actions/build-setup-common/action.yml index aef915c5d0da..8efdca623a2c 100644 --- a/.github/actions/build-setup-common/action.yml +++ b/.github/actions/build-setup-common/action.yml @@ -47,6 +47,9 @@ runs: echo '*** clang++' which clang++ clang++ --version + echo '*** clang-tidy' + which clang-tidy + clang-tidy --version # Add our bazel configuration and print basic info to ease debugging. - name: Configure Bazel and print info diff --git a/.github/actions/build-setup-macos/action.yml b/.github/actions/build-setup-macos/action.yml index 0617ab867440..b6a8e3e1b3bb 100644 --- a/.github/actions/build-setup-macos/action.yml +++ b/.github/actions/build-setup-macos/action.yml @@ -23,14 +23,12 @@ runs: xcrun simctl delete all sudo rm -rf ~/Library/Developer/CoreSimulator/Caches/* - # Install and cache LLVM 16 from Homebrew. Some runners may have LLVM 16, + # Install and cache LLVM 19 from Homebrew. Some runners may have LLVM 19, # but this is reliable (including with libc++), and gives us testing at the # minimum supported LLVM version. - name: Cache Homebrew id: cache-homebrew-macos uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 - env: - cache-name: cache-homebrew with: # Cover all the critical parts of Homebrew here. Homebrew on Arm macOS # uses its own prefix making this easy to cover, but we need a few @@ -47,7 +45,8 @@ runs: ' }} # Note the key needs to include all the packages we're adding. - key: Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }} + key: + Homebrew-Cache-${{ inputs.matrix_runner }}-${{ runner.arch }}-llvm@19 - name: Install LLVM and Clang with Homebrew if: steps.cache-homebrew-macos.outputs.cache-hit != 'true' @@ -61,11 +60,11 @@ runs: LEAVES=$(brew leaves | egrep -v '^(bazelisk|gh|git|git-lfs|gnu-tar|go@.*|jq|pipx|node@.*|openssl@.*|wget|yq|zlib)$') brew uninstall -f --ignore-dependencies $LEAVES echo '*** Installing LLVM deps' - brew install --force-bottle --only-dependencies llvm@16 + brew install --force-bottle --only-dependencies llvm@19 echo '*** Installing LLVM itself' - brew install --force-bottle --force --verbose llvm@16 - echo '*** brew info llvm@16' - brew info llvm@16 + brew install --force-bottle --force --verbose llvm@19 + echo '*** brew info llvm@19' + brew info llvm@19 echo '*** brew autoremove' brew autoremove echo '*** brew info' @@ -78,7 +77,7 @@ runs: - name: Setup LLVM and Clang shell: bash run: | - LLVM_PATH="$(brew --prefix llvm@16)" + LLVM_PATH="$(brew --prefix llvm@19)" echo "Using ${LLVM_PATH}" echo "${LLVM_PATH}/bin" >> $GITHUB_PATH echo '*** ls "${LLVM_PATH}"' diff --git a/.github/actions/build-setup-ubuntu/action.yml b/.github/actions/build-setup-ubuntu/action.yml index 67682f154516..34f51b5f6679 100644 --- a/.github/actions/build-setup-ubuntu/action.yml +++ b/.github/actions/build-setup-ubuntu/action.yml @@ -22,48 +22,22 @@ runs: # to save time. large-packages: false - # Cache and install a recent version of LLVM. This uses the GitHub action - # cache to avoid directly downloading on each iteration and improve - # reliability. - - name: Cache LLVM and Clang installation - id: cache-llvm-ubuntu - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 - env: - cache-name: cache-llvm - with: - path: ~/llvm - key: LLVM-16-Cache-ubuntu-${{ runner.arch }} + - name: Show system LLVM and Clang installation + shell: bash + run: | + dpkg -l '*clang*' '*llvm*' + # Install a recent version of LLVM. We use LLVM's apt.llvm.org in order to + # have access to all released versions, instead of the GitHub releases which + # are often missing binaries for ubuntu x64. - name: Download LLVM and Clang installation - if: steps.cache-llvm-ubuntu.outputs.cache-hit != 'true' + env: + clang_version: 19 shell: bash run: | - cd ~ - LLVM_RELEASE=clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04 - echo "*** Downloading $LLVM_RELEASE" - wget --show-progress=off "https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.4/$LLVM_RELEASE.tar.xz" - echo "*** Extracting $LLVM_RELEASE" - tar -xJf "$LLVM_RELEASE.tar.xz" - echo "*** Moving to 'llvm'" - mv "$LLVM_RELEASE" llvm - echo "*** Testing `clang++ --version`" - ~/llvm/bin/clang++ --version + echo '*** Installing upstream clang packages' + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${clang_version} all - # The installation contains *huge* parts of LLVM we don't need for the - # toolchain. Prune them here to keep our cache small. - echo "*** Cleaning the 'llvm' directory" - rm llvm/lib/{*.a,*.so,*.so.*,*.bc} - rm llvm/bin/{flang-*,mlir-*,clang-{scan-deps,check,repl},*-test,llvm-{lto*,reduce,bolt*,exegesis,jitlink},bugpoint,opt,llc} - echo "*** Size of the 'llvm' directory" - du -hs llvm - - - name: Setup LLVM and Clang paths - shell: bash - run: | - LLVM_PATH=~/llvm - echo "Using ${LLVM_PATH}" - echo "${LLVM_PATH}/bin" >> $GITHUB_PATH - echo '*** ls "${LLVM_PATH}"' - ls "${LLVM_PATH}" - echo '*** ls "${LLVM_PATH}/bin"' - ls "${LLVM_PATH}/bin" + echo "/lib/llvm-19/bin" >> "$GITHUB_PATH" diff --git a/.github/workflows/clang_tidy.yaml b/.github/workflows/clang_tidy.yaml index d23c0f47a759..d4c299cb3bb1 100644 --- a/.github/workflows/clang_tidy.yaml +++ b/.github/workflows/clang_tidy.yaml @@ -22,7 +22,7 @@ concurrency: jobs: clang-tidy: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Harden Runner @@ -51,7 +51,7 @@ jobs: - id: test-setup uses: ./.github/actions/test-setup with: - matrix_runner: 'ubuntu-22.04' + matrix_runner: 'ubuntu-24.04' base_sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || diff --git a/.github/workflows/nightly_release.yaml b/.github/workflows/nightly_release.yaml index 2019a6fc2c23..7695e519e6cf 100644 --- a/.github/workflows/nightly_release.yaml +++ b/.github/workflows/nightly_release.yaml @@ -34,7 +34,7 @@ permissions: jobs: release: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Harden Runner uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 @@ -68,7 +68,7 @@ jobs: - uses: ./.github/actions/build-setup-common with: - matrix_runner: ubuntu-22.04 + matrix_runner: ubuntu-24.04 remote_cache_upload: ${{ env.remote_cache_upload }} - name: Get nightly date diff --git a/.github/workflows/pre_commit.yaml b/.github/workflows/pre_commit.yaml index 97c742abf8f5..d4de5ee8df33 100644 --- a/.github/workflows/pre_commit.yaml +++ b/.github/workflows/pre_commit.yaml @@ -15,12 +15,11 @@ permissions: jobs: pre-commit: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Harden Runner uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: - disable-sudo: true egress-policy: block # When adding endpoints, see README.md. # prettier-ignore @@ -46,7 +45,7 @@ jobs: # Ensure LLVM is set up consistently. - uses: ./.github/actions/build-setup-common with: - matrix_runner: ubuntu-latest + matrix_runner: ubuntu-24.04 remote_cache_upload: '--remote_upload_local_results=false' - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index bf53d7f5eac7..8ee263923ea9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -25,7 +25,7 @@ jobs: strategy: matrix: # Test a recent version of each supported OS. - runner: ['ubuntu-22.04', 'macos-14'] + runner: ['ubuntu-24.04', 'macos-14'] build_mode: [fastbuild, opt] runs-on: ${{ matrix.runner }} diff --git a/common/ostream.h b/common/ostream.h index 56c06a74652f..cd79bb75e42f 100644 --- a/common/ostream.h +++ b/common/ostream.h @@ -20,6 +20,7 @@ namespace Carbon { // CRTP base class for printable types. Children (DerivedT) must implement: // - auto Print(llvm::raw_ostream& out) const -> void template +// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) class Printable { // Provides simple printing for debuggers. LLVM_DUMP_METHOD auto Dump() const -> std::string { diff --git a/docs/project/contribution_tools.md b/docs/project/contribution_tools.md index 593980200f2f..cb8b360e979c 100644 --- a/docs/project/contribution_tools.md +++ b/docs/project/contribution_tools.md @@ -50,8 +50,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 16, our minimum version. That needs -# the number of the `:` in the output to be over 16. For example, `1:16.0-57`. +# 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`. apt-cache show clang | grep 'Version:' # Install tools. @@ -88,25 +88,28 @@ it to your `$PATH`, and aliasing `bazel` to it. #### Old `clang` versions -If the version of `clang` is earlier than 16, you may still have version 16 +If the version of `clang` is earlier than 19, you may still have version 19 available. You can use the following install instead: ```shell # Install explicitly versioned Clang tools. sudo apt install \ - clang-16 \ - libc++-16-dev \ - libc++abi-16-dev \ - lld-16 \ - lldb-16 + clang-19 \ + libc++-19-dev \ + libc++abi-19-dev \ + lld-19 \ + lldb-19 # 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-16))" >> user.bazelrc +echo "build --repo_env=CC=$(readlink -f $(which clang-19))" >> user.bazelrc ``` -> NOTE: Most LLVM 16+ installs should build Carbon. If you're having issues, see +And if it's not available directly from the distribution, you can install Clang +tools on Debian/Ubuntu from . + +> NOTE: Most LLVM 19+ installs should build Carbon. If you're having issues, see > [troubleshooting build issues](#troubleshooting-build-issues). ### macOS @@ -245,13 +248,11 @@ considering if they fit your workflow. The required setup for LLDB is: -1. Install a minimum of LLVM 19 instead of LLVM 16. - - The `lldb-dap` tool was added as part of LLVM 19. -2. In the `.vscode` subdirectory, symlink `lldb_launch.json` to `launch.json`. +1. In the `.vscode` subdirectory, symlink `lldb_launch.json` to `launch.json`. For example: `ln -s lldb_launch.json .vscode/launch.json` -3. Install the +2. Install the [`llvm-vs-code-extensions.lldb-dap` extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap). -4. In VS Code settings, it may be necessary to set `lldb-dap.executable-path` +3. In VS Code settings, it may be necessary to set `lldb-dap.executable-path` to the path of `lldb-dap`. A typical debug session looks like: @@ -305,8 +306,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 16. If you see an older -version, please update, or use the special `clang-16` instructions above. +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. 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 @@ -323,7 +324,7 @@ providing the output of the following diagnostic commands: ```shell echo $CC which clang -which clang-16 +which clang-19 clang --version grep llvm_bindir $(bazel info workspace)/bazel-execroot/external/+clang_toolchain_extension+bazel_cc_toolchain/clang_detected_variables.bzl