[clang] [clang] Only build static analyzer sources if requested (PR #71653)

Shoaib Meenai via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 13 22:30:37 PST 2023


================
@@ -23,7 +23,9 @@ add_subdirectory(Tooling)
 add_subdirectory(DirectoryWatcher)
 add_subdirectory(Index)
 add_subdirectory(IndexSerialization)
-add_subdirectory(StaticAnalyzer)
+if(CLANG_ENABLE_STATIC_ANALYZER)
----------------
smeenai wrote:

I agree with Chris in general. This case is a bit different because the static analyzer sources would be included in Clang otherwise instead of being a standalone target you could just not build (roughly analogous to `LLVM_TARGETS_TO_BUILD`), but what are the concrete savings (build time, binary size, etc.) from the option, to weigh against the added build complexity?

I see some unguarded uses of the static analyzer libraries, e.g. `clang/tools/clang-check/CMakeLists.txt` unconditionally references `clangStaticAnalyzerFrontend`, so those would need to be adjusted as well if we went this route. It seems like that can get easily broken in the future as well though.

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


More information about the cfe-commits mailing list