Closed whisperity closed 3 days ago
@llvm/issue-subscribers-clang-static-analyzer
Author: None (whisperity)
@llvm/issue-subscribers-bug
Author: None (whisperity)
This has been rejected in https://github.com/llvm/llvm-project/pull/71653 fwiw.
This has been rejected in #71653 fwiw.
@tbaederr Then we should be revisit that issue. It's been almost a year and the comments in that patch do not apply and neither fixes nor removals had been made since. But I will continue the discussion there.
Currently, I am working on tasks for which building or having the Clang Static Analyzer is completely irrelevant professionally, but having to sit through CSA builds due to changes in code that causes CSA recompilations is a waste of time. I found the CMake options documented as toggleables (they show up in
ccmake
even without advanced options)CLANG_ENABLE_STATIC_ANALYZER
, and turned it toOFF
. I also had toOFF
its dependencyCLANG_ENABLE_ARCMT
due to a scripted error message instructing me to do so.Having done so, I can confirm that doing
ninja clang
does not build CSA-related things; thatclang --analyze foo.cpp
correctly reports the at-first little bit crypticerror: action RunAnalysis not compiled in
. And indeed,lib/libclangStaticAnalyzerCheckers.a
is not created. This is true forninja clang
when it is explicitly specified.The other problem is that I often change tools which work best if the entire LLVM build directory is incrementally recompiled, as opposed to always needing to remember the most restrictive build target that actually achieves my current goal at that moment. For this,
ninja
— orninja all
in its full form — is a good command because the build system deals with the incrementality of the compilation. (Usually I do this because I have some other scripts that depend on having "most" of the usual contents of a fullbin/
directory such asllvm-readelf
, and it's simply much easier to do it this way than listing out all the "binutils" needed.)But this is broken for
CLANG_ENABLE_STATIC_ANALYZER=OFF
! If in an incremental compilation scenario following a successful build of all top-level binaries I — perhaps accidentally — runninja all
, I get about 202 further build actions executed, and despite thatclang --analyze ...
still reports the inability to execute CSA,lib/libclangStaticAnalyzerCheckers.a
is assembled andtools/clang/lib/StaticAnalyzer
is populated with object files.This is unexpected and unconventional. For example, we disable specific not important
LLVM_TARGETS_TO_BUILD
for development and deployment and doingninja llvm
does not cause thellc
binary to be able to assemble for the disabled targets.These two elements of the build directory take up 1.1 + 1.5 = 2.6 GiB of space, which is almost 10% of the total size of the build directory.