[clang] Reapply "[cmake] Refactor clang unittest cmake" (PR #134195)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 9 23:23:00 PDT 2025


HighCommander4 wrote:

> > Do I understand correctly that, as a result of this commit, the SemaTests target no longer exists, and to work on / run the tests that it used to include (such as HeuristicResolverTest.cpp), I have to build the ClangdUnitTests target, which requires building 1000+ test source files that I otherwise wouldn't need?
> 
> Yes and no: You need to build most clang code and most clang unittests, but clangd is its own subproject, and wasn't affected by this change.
> 
> I think the main change that would explain an increase in compile actions is that AllClangUnitTests includes clangCodeGen, which depends on LLVM, so if you want to run one Sema test, previously you would not need to build LLVM, but now you do.

I don't think that's it; I was already building LLVM because the `clang` target needs it (and I need the `clang` target to run lit tests in e.g. `clang/test/CodeCompletion`). I think it's just the extra unit test source files themselves that `ClangUnitTests` includes, beyond the ones that were present in `SemaTests`.

> This may negatively impact cold builds or builds-after-syncing due to the coarser-grained dependencies, but incremental builds should be nearly as fast. Are you observing something else, and if so, what CMake generator are you using?

You are correct that only cold builds and builds-after-syncing are affected, but that still seems unfortunate to me from a developer experience point of view.

I noticed that in https://github.com/llvm/llvm-project/commit/afd738cd9016ddef4e26b309770ba35fd017a178, a couple of small test binaries were split out from `ClangUnitTests`. How would you feel about doing the same to `SemaTests`, which was similarly a small binary (just 6 unit test source files)?

https://github.com/llvm/llvm-project/pull/134195


More information about the cfe-commits mailing list