Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

Finding version-suffixed Clang analyzers from `PATH` not working, even with `CC_ANALYZERS_FROM_PATH=1` #3673

Open whisperity opened 2 years ago

whisperity commented 2 years ago

Describe the bug The logic that finds version-suffixed Clang binaries (from self-built entities or from PPA) does not work, it just keeps saying

[WARNING][2022-05-21 11:20:28] {analyzer} [14955] <140279203762176> - analyzer_types.py:122 print_unsupported_analyzers() - Analyzer 'clang-tidy' is enabled but CodeChecker is failed to execute analysis with it: 'Failed to detect analyzer binary!'. Please check your 'PATH' environment variable and the 'config/package_layout.json' file!

CodeChecker version v6.19.1, installed from PyPI

To Reproduce Steps to reproduce the behaviour:

  1. Create a new Docker image, apt install python3 python3-pip software-properties-common wget curl
  2. Install LLVM from PPA: bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
  3. Ensure that Clang and Clang-Tidy is installed: apt install clang-14 clang-tidy-14 (replace with latest non-rolling version number appropriately)
  4. which clang clang++ clang-tidy returns "not found"
  5. which clang-14 clang++-14 clang-tidy-14 returns the binaries under /usr/bin
  6. echo $PATH | grep "/usr/bin" matches
  7. CC_ANALYZERS_FROM_PATH=yes CodeChecker check -b "clang++-14 -UNDEBUG -std=c++17 main.cpp" -o Reports
  8. It says analysers are not found.

Expected behaviour Pick up the only installed version of Clang in the current environment and run the analysis with it.

Desktop (please complete the following information)

Additional context

╰─ cat /usr/local/share/codechecker/config/package_layout.json
{
  "runtime": {
    "analyzers": {
      "clangsa": "clang",
      "clang-tidy": "clang-tidy"
    },
    "clang-apply-replacements": "clang-apply-replacements"
  },
  "ld_lib_path_extra" : [],
  "path_env_extra" : []
}

While certainly if I have the right to install packages I would have the right to just edit this config file (and putting clang-14 and clang-tidy-14 in it makes the issue disappear), it is not always the case, and this just makes the PyPI package unusable in a restricted environment...

elupus commented 1 year ago

This hit me as well. I couldn't find a way to supply the path to clangsa from command line or in the supplied config json.