-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[analyzer] Add support the CC_ANALYZER_BIN env var #4057
Conversation
98ca58f
to
5ebdd4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me something is still not OK.
export CC_ANLAYZER_BIN=gcc:/usr/bin/gcc-13
$ CodeChecker analyzers
clangsa /local/workspace/llvm-project/build/bin/clang-16 18.0.0
clang-tidy /local/workspace/llvm-project/build/bin/clang-tidy 18.0.0
cppcheck /usr/bin/cppcheck 1.90
gcc /usr/bin/x86_64-linux-gnu-g++-9 9.4.0
[WARNING 2023-10-24 20:16] - Can't analyze with 'gcc': Incompatible version: GCC binary found is too old at v9.4.0; minimum version is 13.0.0. Maybe try setting an absolute path to a different analyzer binary via the env variable CC_ANALYZER_BIN?
am I doing something wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This environmental variable can be used the specify the absolute path of an analyzer. Similar to Ericsson#4041, but this is the only solution we can realistically get though the door.
060c50f
to
34a1601
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the following stackrace when no binary is set and I invoke CodeChecker analyzers
Traceback (most recent call last):
File "/ws/codechecker/build/CodeChecker/lib/python3/codechecker_common/cli.py", line 209, in main
sys.exit(args.func(args))
File "/ws/codechecker/build/CodeChecker/lib/python3/codechecker_analyzer/cmd/analyzers.py", line 190, in main
version = analyzer_class.get_binary_version(check_env)
File "/ws/codechecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/cppcheck/analyzer.py", line 88, in get_binary_version
version = [self.analyzer_binary(), '--version']
File "/ws/codechecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/cppcheck/analyzer.py", line 82, in analyzer_binary
return analyzer_context.get_context() \
KeyError: 'cppcheck'
This error does not appear on master.
Cppcheck was not in the path.
AnalyzerContext keeps track of the binaries for each analyzer. However, if the binary isn't found, we don't map None to the respective analyzer, we simply skip it. This lead to key errors when we called the version getter function, which I fixed in this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I am really nitpicking here, but in the future, maybe we can print binary not found
in place of the ERROR
word, instead of adding a separate warning.
CodeChecker analyzers
clangsa /usr/lib/llvm-10/bin/clang 10.0.0
clang-tidy /usr/lib/llvm-10/bin/clang-tidy 10.0.0
cppcheck ERROR
gcc /usr/bin/x86_64-linux-gnu-g++-9 9.4.0
[WARNING 2023-10-26 16:55] - Can't analyze with 'cppcheck': Failed to detect analyzer binary!
[WARNING 2023-10-26 16:55] - Can't analyze with 'gcc': Incompatible version: GCC binary found is too old at v9.4.0; minimum version is 13.0.0. Maybe try setting an absolute path to a different analyzer binary via the env variable CC_ANALYZER_BIN?
This environmental variable can be used the specify the absolute path of
an analyzer. Similar to #4041, but this is the only solution we can
realistically get though the door.
Here is a glimpse of how the error messages look like:
Depends on #4056.