Open-Source Wikis

/

LLVM

/

How to contribute

/

Tooling

llvm/llvm-project

Tooling

The build system, code generators, and helper scripts that sit under the user-facing source.

CMake

The whole monorepo is configured with CMake from llvm/CMakeLists.txt as the entry point. LLVM_ENABLE_PROJECTS selects which compiler/tool subprojects join the build, and LLVM_ENABLE_RUNTIMES selects which runtime libraries do. Per-project CMake files are conventional — each subproject has its own top-level CMakeLists.txt that declares its libraries via add_llvm_library / add_llvm_executable and similar wrappers.

Common wrapper macros (defined in llvm/cmake/):

  • add_llvm_library(<name> ...)
  • add_llvm_executable(<name> ...)
  • add_llvm_unittest(<name> ...)
  • tablegen(LLVM ...) — runs llvm-tblgen at configure-time
  • clang_tablegen(...) — same idea, for Clang's .td files
  • mlir_tablegen(...) — and MLIR's

The full set is in llvm/cmake/modules/AddLLVM.cmake. Read that file before adding a new library — there are 30-plus options for export, install, link visibility, and platform behavior.

CMake presets (llvm/CMakePresets.json) provide ready-made configurations:

cmake --list-presets
cmake --preset stage1
ninja -C build

Ninja

LLVM is several million lines and many thousands of targets. Ninja's incremental rebuild story is dramatically better than Make's at this scale. Use -G Ninja at configure time and ninja rather than make.

For incremental development:

ninja -C build opt          # rebuild just `opt` and its deps
ninja -C build clang        # just clang
ninja -C build check-llvm   # rebuild what's needed and run llvm tests

TableGen

TableGen (llvm/lib/TableGen/ — interpreter; llvm/utils/TableGen/ — command-line tool and codegen-emitter "backends") is a build-time DSL that produces *.inc files included by C++.

Subprojects build their own variants:

  • llvm-tblgen — for LLVM core (instructions, intrinsics, attributes, register info, ISel patterns, scheduling)
  • clang-tblgen (clang/utils/TableGen/) — for Clang attributes, diagnostics, options, builtins
  • mlir-tblgen (mlir/tools/mlir-tblgen/) — for MLIR ops, types, attributes, interfaces
  • lldb-tblgen (lldb/utils/TableGen/) — for LLDB property definitions

TableGen invocations declared in CMake produce headers (*.inc) that are #included by the corresponding .cpp. Editing a .td triggers a regeneration; missing or stale generated files are a common cause of confusing build errors after a rebase.

Source-formatting and lint

  • clang-format — config in .clang-format at the repo root and per-subproject overrides. Run clang-format -i on touched files before pushing.
  • clang-tidy — config in .clang-tidy and per-subproject overrides. Not enforced in CI for the bulk of the tree, but useful locally.
  • Spell check / commit-message hooks — handled by GitHub bots, not local hooks.

Update scripts

Many test files have machine-generated ; CHECK: lines. The scripts that produce them live in llvm/utils/:

  • update_test_checks.py — IR-level tests (post-pass output)
  • update_llc_test_checks.pyllc codegen tests (assembly output)
  • update_mir_test_checks.py — MIR tests
  • update_cc_test_checks.py — Clang tests
  • update_analyze_test_checks.pyopt -analyze output

Run them on the test you just edited; they regenerate the FileCheck assertions to match the actual current output.

Other helper tools

  • llvm-lit — the lit test runner (llvm/utils/lit/, built and installed as a Python package).
  • FileCheck — pattern-matcher used by lit (llvm/utils/FileCheck/).
  • not — small wrapper that inverts an exit code, used in tests that expect failure.
  • count — asserts on the number of lines on stdin, used in tests.
  • clang-format-diff.py, git-clang-format — incremental formatting helpers.
  • bisect helpers under llvm/utils/ (e.g. git-llvm, release/test-release.sh).

CI configuration

Pre-commit CI is configured in .ci/ and .github/workflows/. Buildbots external to this repository (lab.llvm.org) cover the long tail — many platforms, sanitizer combinations, and cross-builds. The buildbot configs are in a separate repo (llvm-zorg).

Release tooling

The release process is documented in llvm/docs/HowToReleaseLLVM.rst. The release manager runs scripts under llvm/utils/release/ to cut release branches, run release-test pipelines, and tag.

Bazel build

LLVM's primary build is CMake. A Bazel build also exists at utils/bazel/ for users who prefer Bazel; it is best-effort and maintained as a community service.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Tooling – LLVM wiki | Factory