Repository navigation
build: require LLVM 20, since LLVM 19 no longer compiles the analyzer - #260
Merged
Merged
Conversation
…nalyzer Since 33fe390, src/analysis/ownership/ResourceFactCollector.cpp reads the callee's `captures` attribute through llvm::CaptureInfo, llvm::CaptureComponents, llvm::capturesNothing and llvm::Argument::getAttributes(), which LLVM 20 introduced. CMake still accepted LLVM 19, so a build with it passed configuration and then failed to compile that file. Configuration now stops with the error of check_llvm_version instead.
CMake now requires LLVM 20, so the script would only hand it a version that configuration rejects.
The script takes the first formula it finds, and it tried `llvm` first. Homebrew's `llvm` formula is LLVM 23.1 as of this change, while the analyzer builds with LLVM 20 only (LLVM 21 is tracked in #259), so with both formulas installed the script picked the wrong one. `llvm` stays as the fallback.
The prerequisites still listed LLVM 19 as the minimum, with 20 recommended.
The build section named no LLVM version. It now names the one the analyzer builds with, and how to install it on macOS and Ubuntu.
The second entry covers the action change of #257, which added no changelog entry.
… before LLVM_MIN_REQUIRED_VERSION was a cache variable, and set(CACHE) keeps a value that the cache already holds. A build directory configured before the floor moved to 20 kept 19, so running ./build.sh again after an update still accepted LLVM 19, and the build failed during compilation. check_llvm_version now receives 20 directly, on every configuration. Nothing in the repository set the variable; a command line that still passes it gets CMake's warning about unused variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The analyzer has not compiled with LLVM 19 since 33fe390, yet CMake still accepts LLVM 19 and
scripts/build.shstill looks for it. This PR raises CMake's minimum LLVM version to 20, makesscripts/build.shlook for Homebrewllvm@20first, and updates the documents that name an LLVM version.What breaks
feat(resource-lifetime): MissingRelease from the ownership engine) reads the callee'scapturesattribute insrc/analysis/ownership/ResourceFactCollector.cpp(lines 955 to 966) throughllvm::CaptureInfo,llvm::CaptureComponents,llvm::capturesNothingandllvm::Argument::getAttributes(). All four first appear in LLVM 20, along with thecapturesattribute itself.g++ -fsyntax-onlyagainst apt.llvm.org's packages, that file has 9 errors with LLVM 19.1.7, all in those lines, and none with LLVM 20.1.8.CMakeLists.txtsetsLLVM_MIN_REQUIRED_VERSIONto 19, so a build with LLVM 19 passes configuration and fails during compilation. Every CI job installs LLVM 20, so none of them saw it.scripts/build.shtakes the first Homebrew formula it finds amongllvm,llvm@20,llvm@19andllvm@18. Homebrew'sllvmformula is LLVM 23.1, and the analyzer does not build with LLVM 21 (Build and test with LLVM 21 (Ubuntu 26.04 runners) #259), so withllvmandllvm@20both installed, the script picksllvm.Change
CMakeLists.txt: the version check requires LLVM 20, in new and existing build directories alike. With LLVM 19, configuration now stops withLLVM version 19.1.7 found, but version 20 or higher is required.The minimum goes straight tocheck_llvm_version, instead of through theLLVM_MIN_REQUIRED_VERSIONcache variable:set(CACHE)keeps a value already in the cache, so a build directory configured before this change would have kept 19. Nothing in the repository set that variable; a command line that still passes it gets CMake's warning about unused variables.scripts/build.sh: on macOS, the script looks forllvm@20, thenllvm. It no longer looks forllvm@19orllvm@18, which CMake would reject.CONTRIBUTING.mdlists LLVM/Clang 20 instead of>= 19(20 recommended). The README's build section states that the analyzer builds with LLVM and Clang 20, and how to install them on macOS and Ubuntu.CHANGELOG.md: an entry for this change, and one for fix(action): diagnose unsupported Ubuntu LLVM versions #257, which made the GitHub Action accept LLVM 20 only and added no entry.Not in this PR
scripts/build.shpicks the first/usr/lib/llvm-*directory in alphabetical order, so with the development files of LLVM 18 or 19 next to those of LLVM 20, it picks the older version. CMake now rejects it at configuration, with the error above.Verification
CMake, configured on macOS:
Checking for LLVM >= 19..., thenFound LLVM 19.1.7). It now stops withLLVM version 19.1.7 found, but version 20 or higher is required.mainwith that stub package, reconfiguring with this PR's first version ofCMakeLists.txt(aa648dc) still printedChecking for LLVM >= 19...and accepted it, because the cache kept 19. Reconfiguring with the current version stops with the error above.-DLLVM_MIN_REQUIRED_VERSION=19only produces CMake's warning about unused variables.scripts/build.sh --configure-only, run with stubbrewandcmakecommands, passes CMake the directories of these formulas:llvmandllvm@20llvmllvm@20llvmonlyllvmllvmllvm@19onlyllvm@19LLVM_DIR not foundllvm@18andllvm@20llvm@20llvm@20CI does not run
scripts/build.sh, and every job builds with LLVM 20, so this PR's own run checks that the new minimum accepts it.