[all-commits] [llvm/llvm-project] 5cafb6: [CMake] Factor check- target deps to reduce build....

Reid Kleckner via All-commits all-commits at lists.llvm.org
Tue Sep 15 10:14:08 PDT 2026


  Branch: refs/heads/users/rnk/factor-lit-subdir-deps
  Home:   https://github.com/llvm/llvm-project
  Commit: 5cafb669a475074878cf4808df3fe870b856c658
      https://github.com/llvm/llvm-project/commit/5cafb669a475074878cf4808df3fe870b856c658
  Author: Reid Kleckner <rkleckner at nvidia.com>
  Date:   2026-09-15 (Tue, 15 Sep 2026)

  Changed paths:
    M llvm/cmake/modules/AddLLVM.cmake

  Log Message:
  -----------
  [CMake] Factor check- target deps to reduce build.ninja size by 45%

Many LLVM developers are not aware, but our lit CMake logic creates a
check-* target for every eligible subdirectory inside a lit test suite.
There are thousands of these targets; in the benchmark configuration:

```
❯ ninja -C build -t targets all | grep '^check-' | wc -l
2667
```

Chris Bieneman originally added this feature in March 2015. The original
change suppressed these targets for Xcode and Visual Studio because the
target clutter hurt IDE usability; rL344555 later generalized that
behavior behind LLVM_ENABLE_IDE.

When using the Ninja generator, each of these check-${proj}-${subdir}
targets repeats its suite's transitive test dependencies, like so:

```
build .../check-clang-sema-aarch64: \
    bin/FileCheck bin/apinotes-test bin/c-index-test bin/clang \
    bin/clang-check bin/clang-diff bin/clang-extdef-mapping \
    bin/clang-fuzzer-dictionary bin/clang-import-test \
    ... \
    bin/count bin/diagtool bin/llc bin/lld bin/llvm-ar bin/llvm-as \
    bin/llvm-bcanalyzer bin/llvm-cat bin/llvm-config bin/llvm-cxxfilt \
    ...
```

In a large LLVM configuration this accounts for tens of megabytes of
generated Ninja input and 30% of Ninja generation time.

For the single-config Ninja generator with CMake 3.27 and newer, this
change factors the dependencies behind a stamp file. The makefile
generator doesn't repeat transitive target dependencies the same way, so
it and other generators retain the existing implementation.

This feature relies on the CMake 3.27 feature DEPENDS_EXPLICIT_ONLY:
https://cmake.org/cmake/help/v3.27/command/add_custom_command.html#command:add_custom_command
We are raising the minimum to 3.31 soon, so this won't be relevant for
very long.

Fresh-configure benchmark using CMake 3.31.12 and Ninja 1.10.2 with the same
Release configuration and LLVM, Clang, clang-tools-extra, LLD, MLIR, Flang,
and Polly enabled:

| Metric               |        Before |         After |                 Change |
|----------------------|--------------:|--------------:|-----------------------:|
| Configure            |        22.8 s |        21.9 s |        -0.9 s  (-3.9%) |
| Generate             |        13.2 s |         9.2 s |        -4.0 s (-30.3%) |
| Wall time            |       37.63 s |       32.23 s |       -5.40 s (-14.4%) |
| build.ninja          | 171,227,951 B |  93,102,750 B | -78,125,201 B (-45.6%) |
| rules.ninja          |   1,048,691 B |   1,048,691 B |              unchanged |
| Combined Ninja files | 172,276,642 B |  94,151,441 B | -78,125,201 B (-45.3%) |

As a rough estimate of the cost of the entire per-directory target
feature, I also ran an immediately paired fresh configure with
LLVM_ENABLE_IDE=ON, which skips add_lit_testsuites as well as some other
non-IDE targets. The normal optimized configuration took 11.4 s to
configure, 5.3 s to generate, and 17.32 s wall time; IDE mode took 10.5
s, 4.3 s, and 16.04 s respectively. The delta suggests that the entire
feature now costs at most 1.3 s wall time, so it seems worth keeping.

The per-directory check-* entry points are not exercised by pre-merge, so I
manually tested these:

- check-llvm-assembler: 535 passed.
- check-clang-lexer: 142 passed, 6 unsupported.
- check-mlir-ir: 114 passed.
- check-flang-parser: 204 passed.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list