[analyzer] Add the 'executable' config to all analyzers
By default, we look for clang, clang-tidy, gcc, etc. These binaries (and compilers in general) are notorious for having their version number in the binary name, making it difficult to run clang++-16 instead of clang++. Its not impossible, but really inconvenient, hence this patch.
We debated a few approaches to this (including a CodeChecker-wide option called --analyzer-binary, that could havve been used like this: --analyzer-binary clangsa:/usr/bin/clang-16
We decided that since not all analyzers might have an executable binary (like pylint), we shouldn't commit to this naming. We also decided that this is a flag that should be implemented by individual analyzer plugins.
The PR adds the 'executable' config to all currently supported analyzers.
I also needed to make adjustments to CodeChecker analyzers, since the
new config must be visible, even if we couldn't get hold of an analyzer
binary that we support. The list of changes:
- Deprecate both
--alland--details, because they were more confusing than useful - We list all supported (not available) analyzers by default, but print a warning message when its not available.
- We used to query the version of each analyzer binary in a uniform way, but clang, cppcheck, gcc prints their version using different flags, and in different formats. I changed this to call the analyzer plugins' get_binary_version method (which I also implemented in this patch).
I don't like enlarging patches too much, but this is how the PR turned out. Its honestly not my proudest work (you can only do so much in so little time), but I think the interface is fine, even if the implementation can use a little improvement.
Closes https://github.com/Ericsson/codechecker/issues/3898.
I think, that even if we merge this PR now, this options should be introduced as an analyzer config option by the final 6.23.0 release. The analyzer binary could be given through --analyzer-config.
This is kind of a dealbreaker for gcc support. It is in our best interest that the community has at least a somewhat convenient way to make CodeChecker accept gcc-13.
Some examples for CodeChecker analyzers:
gcc-13 is available:
$ CodeChecker analyzers -o table
---------------------------------------------------------------------------------------
Name | Path | Version
---------------------------------------------------------------------------------------
clangsa | (my absolute path)/llvm-project/releaseBuild/bin/clang-17 | 16.0.4
clang-tidy | (my absolute path)/llvm-project/releaseBuild/bin/clang-tidy | 16.0.4
cppcheck | /usr/bin/cppcheck | 2.7
gcc | /usr/lib/ccache/gcc-13 | 13.1.0
---------------------------------------------------------------------------------------
gcc-13 is NOT available:
$ CodeChecker analyzers -o table
---------------------------------------------------------------------------------------
Name | Path | Version
---------------------------------------------------------------------------------------
clangsa | (my absolute path)/llvm-project/releaseBuild/bin/clang-17 | 16.0.4
clang-tidy | (my absolute path)/llvm-project/releaseBuild/bin/clang-tidy | 16.0.4
cppcheck | /usr/bin/cppcheck | 2.7
gcc | /usr/lib/ccache/gcc | 11.4.0
---------------------------------------------------------------------------------------
[WARNING 2023-10-20 12:17] - Can't analyze with 'gcc': Incompatible version: GCC binary found is too old at v11.4.0; minimum version is 13.0.0.
gcc-13 is available:
$ CodeChecker analyzers --analyzer-config=gcc -o table # gcc-13 is available
------------------------------------------------------------------------------------------------------------------------------
Option | Description
------------------------------------------------------------------------------------------------------------------------------
gcc:executable | Use the specified analyzer binary. This supersedes any other method CodeChecker might use to get hold of one.
------------------------------------------------------------------------------------------------------------------------------
gcc-13 is NOT available:
$ CodeChecker analyzers --analyzer-config=gcc -o table
------------------------------------------------------------------------------------------------------------------------------
Option | Description
------------------------------------------------------------------------------------------------------------------------------
gcc:executable | Use the specified analyzer binary. This supersedes any other method CodeChecker might use to get hold of one.
------------------------------------------------------------------------------------------------------------------------------
[WARNING 2023-10-20 12:18] - Can't analyze with 'gcc': Incompatible version: GCC binary found is too old at v11.4.0; minimum version is 13.0.0.
$ CodeChecker analyzers --analyzer-config=cppcheck -o table
-------------------------------------------------------------------------------------------------------------------------------------
Option | Description
-------------------------------------------------------------------------------------------------------------------------------------
cppcheck:executable | Use the specified analyzer binary. This supersedes any other method CodeChecker might use to get hold of one.
cppcheck:addons | A list of cppcheck addon files.
cppcheck:libraries | A list of cppcheck library definiton files.
cppcheck:platform | The platform configuration .xml file.
cppcheck:inconclusive | Enable inconclusive reports.
-------------------------------------------------------------------------------------------------------------------------------------
Something does not seem to be right
CodeChecker analyze ./compile_commands.json --analyzer-config gcc:executable=/usr/bin/gcc-13 -o reports_gcc
I get this error Analyzer 'gcc' is enabled but CodeChecker is failed to execute analysis with it: 'Incompatible version: GCC binary found is too old at v9.4.0; minimum version is 13.0.0.'. Please check your 'PATH' environment variable and the 'config/package_layout.json' file!