<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117705>117705</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][analyzer][build] Do not build the Static Analyzer for `ninja all` if disabled by `CLANG_ENABLE_STATIC_ANALYZER=OFF`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
cmake,
clang:static analyzer,
build-problem
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
whisperity
</td>
</tr>
</table>
<pre>
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 to `OFF`. I also had to `OFF` its dependency `CLANG_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; that `clang --analyze foo.cpp` correctly reports the at-first little bit cryptic `error: action RunAnalysis not compiled in`. And indeed, `lib/libclangStaticAnalyzerCheckers.a` is not created. This is true for `ninja 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` — or `ninja 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 full `bin/` directory such as `llvm-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 — run `ninja all`, I get about 202 further build actions executed, and despite that `clang --analyze ...` still reports the inability to execute CSA, `lib/libclangStaticAnalyzerCheckers.a` is assembled and `tools/clang/lib/StaticAnalyzer` is populated with object files.
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVs1v2zoS_2voyyCCRH81Bx8cp3kbIO0CbXaB3UtBUSNrXihS4FD2-v31i6Hk1H3d7uGd4ljUfPy-TMNMR4-4U-sHtX5cmDF1Ie7OHfGAkdJlUYfmsjuMMaJP7qL0AZ7B9HAO8Y38EYKHZPiNoQ0Rzh3ZDuqRXJOfRejMST6lDuHgjD_C12QSWdh74y5_YARisKEfHCZ0F6AY0eHJ-ARDDC0yU_DGTX3rMb3XC8CUIHUxjMcODl_3U1eGZkR5ajvjj8hAHmxoEFJnElgzMnI-HVG6kjOJgmeZwsDZcEIILSTqsYBnaMPom2n2T-YNIQzT6SbYsUefsAHDkMLx6NDUDhmU_pA6vAB34QzjIO3VprS2N2-oNiXgCT2cKXVhTGCak_EWm2tdpe_l9OFl__m3bx8_7x9ePn77-rp_fT5823_ev_zr3x-_qE0pSBgZa4weGxAUgrz296cntSllbOM4QGeaHx4AJYYGB_QNenv5qdH-y-HTq5ybATTANtIgO2KMIUKPzOaIQJ5THG0SGvp8tAnAoVDlXpX7v038NMEjcJjUYo2Q4FuK_cRDE-SM2pSe_O8GrAgjtw4Zwr3Sex_S9GHiVTi7i-iMzJM68kdWy4epmgCcpXV3ZyZVQRtCYYdBatoQI9rkLhBxCDFx5tOku5YiJ3CUkkOoKYGNl0GkqTZl3lgt92CsMANfRp8Fy8TgQ4JJO4K-z5jvvXxsEBvZWG1KR7XST47qPNmk-avkDx3aN4xcmEzLXDGi7FbAa0dZjimOmD31M0znDr3wTgz4n8GRJVmPB7TUEjYzE68dQkgdRnFS7bDPVQWwZwhtQj97BFIIjmfriquhRk5AbQYKfaKI8PLyz08zEw0JniFepB55G1GsIB59N9UEg2EIwxAYsxCNO5sLg0dsZgPLi32NMffpAyeIyCmSTXTCuVky8YhpGtvYNOY2xnaEJ2ToL2CnYIJjMA7MfLIPMlIBT0GKE8-kZBgFQPVRqw-lul_BLb7Gu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