Skip to content

Build and test with LLVM 21 (Ubuntu 26.04 runners) #259

Open

Description

@SizzleUnrlsd

Goal

Build and test the analyzer with LLVM 21, so that the GitHub Action runs on Ubuntu 26.04, which ubuntu-latest now selects.

apt.llvm.org publishes no LLVM 20 for Ubuntu 26.04: its resolute branches are the unversioned one, 21, 22 and 23. #255 asked for one of two outcomes on such runners: LLVM 21 support, or an early error. #257 adds the error: the action accepts LLVM 20 only, and on those runners it stops with a message that names ubuntu-24.04. This issue tracks the other outcome, LLVM 21 support.

Current state

  • Compiler library. The pinned coretrace-compiler, v0.10.0 (b4ad336, cmake/compiler/coretrace-compiler.cmake), does not build with LLVM 21. It stops with 11 errors in compiler.cpp, emit/llvm_output.cpp and instrumentation/alloc.cpp:

    • the clang::DiagnosticsEngine and TextDiagnosticPrinter constructors;
    • CompilerInstance::setInvocation and createDiagnostics;
    • an llvm::Triple where a string was expected;
    • llvm::UseCaptureKind.

    v0.12.0 (5e1bb0d), the latest release, builds with LLVM 16 to 23: its "LLVM versions" workflow passes on Linux with each of them on that commit. The two versions are 360 commits apart, but:

    • include/compilerlib/compiler.h is identical in both. It is the only compilerlib header this repository includes (src/analysis/InputPipeline.cpp, for compile, CompileResult and OutputMode).
    • v0.12.0 still defines cc::compilerlib_static, the target this repository links.
  • Analyzer sources. Checked with g++ -fsyntax-only against LLVM 21.1.8 from apt.llvm.org, three files fail. The other files were not checked, because the full build stops in coretrace-compiler first.

Site Change in LLVM 21
src/analysis/ResourceLifetimeAnalysis.cpp:985, callParamHasNonCaptureLikeAttr llvm::Attribute::NoCapture is removed, replaced by the captures attribute
src/analysis/StackPointerEscapeModel.cpp:160, callParamHasNonCaptureLikeAttr same
src/analysis/ownership/ResourceFactCollector.cpp:958 same
src/analysis/ResourceLifetimeAnalysis.cpp:1321, localAddressEscapesToUnmodeledCall llvm::isNonEscapingLocalObject is removed from CaptureTracking.h
  • CI. Every job builds and tests with LLVM 20. "Test GitHub Action" runs on ubuntu-24.04, and the action's llvm-version defaults to 20.

Changes

1. Update coretrace-compiler to v0.12.0

Fix: set GIT_TAG to 5e1bb0d5d39595e30977fc73f5b0172a8451ded5 (v0.12.0). This change can land on its own, still with LLVM 20, before the others.

The two versions are 360 commits apart, so the update needs the checks that #223 listed for the previous one:

  • the CI of the pull request;
  • release-binaries.yml;
  • the Docker images;
  • the self-analysis diagnostics, compared with those of main.

2. llvm::Attribute::NoCapture

CallBase::doesNotCapture(unsigned) exists in both versions:

  • in LLVM 20, it is true for a byval argument, or when nocapture applies to the argument;
  • in LLVM 21, it is capturesNothing(getCaptureInfo(OpNo)).

Fix: at the three sites, call it in place of paramHasAttr(i, llvm::Attribute::NoCapture). No version check is needed.

3. llvm::isNonEscapingLocalObject

In LLVM 20, isNonEscapingLocalObject(V) returns isIdentifiedFunctionLocal(V) && !PointerMayBeCaptured(V, /*ReturnCaptures=*/false, /*StoreCaptures=*/true) (llvm/lib/Analysis/CaptureTracking.cpp). sourceSlot is an alloca, which is always function-local, so only the PointerMayBeCaptured test matters.

Fix: call PointerMayBeCaptured directly, with one call per version behind #if LLVM_VERSION_MAJOR >= 21:

  • LLVM 20: !llvm::PointerMayBeCaptured(&sourceSlot, false, true);
  • LLVM 21: !llvm::PointerMayBeCaptured(&sourceSlot, false).

A single call cannot serve both versions. LLVM 21 removed the StoreCaptures parameter, and the third parameter is now MaxUsesToExplore. The LLVM 20 call therefore still compiles with LLVM 21, but there true limits the search to one use. For an example of this version split, see coretrace-compiler's src/compilerlib/instrumentation/capture_compat.hpp.

4. CI and the action

  • Add a job that builds and tests with LLVM 21. apt.llvm.org publishes LLVM 19 to 23 for noble, so the job can run on ubuntu-24.04. Keep the LLVM 20 jobs.
  • In action.yml, accept llvm-version: 21, and run "Test GitHub Action" on ubuntu-26.04 with that version.
  • Decide whether the default llvm-version stays 20. With 20, the action still stops on ubuntu-latest.
  • Update the requirement in the README notes, which fix(action): diagnose unsupported Ubuntu LLVM versions #257 adds.

Not checked

  • The analyzer files other than the three above, with LLVM 21.
  • A build and test run with v0.12.0, with either LLVM version.
  • LLVM 22 and 23, which apt.llvm.org also publishes for Ubuntu 26.04.

Acceptance

  • CI builds the analyzer and passes its tests with LLVM 20 and with LLVM 21.
  • The action runs on ubuntu-26.04 with llvm-version: 21, and "Test GitHub Action" covers that runner.
  • On ubuntu-24.04 with LLVM 20, the action behaves as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions