heinezen · GitHub

@haytham918

Copy link Copy Markdown

Contributor

Addressing the issue in #1060. Added clang-tidy check on files inside "libopenage" directory, focusing on "clang-analyzer", "bugprone", "concurrency", and "performance" issues. @heinezen

@haytham918

Copy link Copy Markdown

Contributor Author

I think make checkall doesn't work for your workflow because it didn't detect installed clang-tidy

@heinezen heinezen linked an issue

Nov 18, 2024

that may be closed by this pull request

Closed

@heinezen

Copy link Copy Markdown

Member

@TheJJ kevin needs clang-tidy to be installed

@heinezen

Copy link Copy Markdown

Member

@haytham918

Copy link Copy Markdown

Contributor Author

@heinezen Thank you for the notice. I have updated it accordingly.

TheJJ

@haytham918

@heinezen

Copy link Copy Markdown

Member

@TheJJ Did you add clang-tidy already?

@haytham918

Copy link Copy Markdown

Contributor Author

@heinezen @TheJJ , I hope you are doing well with the new year :), any updates on this request?

@heinezen

Copy link Copy Markdown

Member

@haytham918 Happy new year! I'm still waiting for @TheJJ to add clang-tidy to the CI machine.

@TheJJ

Copy link Copy Markdown

Member

It's in the image now :)

@haytham918

Copy link Copy Markdown

Contributor Author

-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:34 (project):
  No CMAKE_CXX_COMPILER could be found.
  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
Error: Process completed with exit code 1.

This is what I am seeing from the build output, not sure what exactly is going wrong with the configuration? I don't think I have ever modified the CMake files.

@TheJJ

Copy link Copy Markdown

Member

Kevin is now able to run clang-tidy, but produces many errors.
The cause of this seems to be the invocation of clang-tidy, which must be integrated into the buildsystem (cmake), because only there the correct compiler invocations are available :)

@haytham918

Copy link Copy Markdown

Contributor Author

Now clang-tidy seems to be working and generating warnings?

@simonsan

Copy link Copy Markdown

Contributor

I think the compile command database needs to be added like this: https://stackoverflow.com/questions/63944447/how-to-specify-compilation-database-for-clang-tidy#71826250

-p ${CMAKE_BUILD_DIR}, also not -DCMAKE_EXPORT_COMPILE_COMMANDS=ON needs to be set to get the compile_commands.json if not already set.

-p <build-path> is used to read a compile command database.
        For example, it can be a CMake build directory in which a file named
        compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
        CMake option to get this output). When no build path is specified,
        a search for compile_commands.json will be attempted through all
        parent paths of the first input file . See:
        https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an
        example of setting up Clang Tooling on a source tree.

@TheJJ

Copy link Copy Markdown

Member

we have the compile command export already. but we need to make clang-tidy to use it, i.e. by integrating it in the buildsystem. it can't run without cmake running before it.

the warnings it currently generates are not helpful since they fail at things like unknown includes, but once it's integrated into the real compile environment, real output is generated :)

@mikonse

Copy link Copy Markdown

Member

@TheJJ

Copy link Copy Markdown

Member

@heinezen

heinezen

Copy link Copy Markdown

Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to finally conclude the question of whether we include clang-tidy in the CI checks or how it should be integrated in the sanity check process, I added a compromise solution. Basically, there's now a new make command checkmerge which tests the same stuff as before and is now also used by kevin. checkall still tests everything, including clang-tidy, but is not used for CI checks. I hope that makes everybody happy :D

@heinezen

Merged

Read the original on github.com ↗