All of lore.kernel.org
 help / color / mirror / Atom feed
* About meson clang-tidy issue on some repos
@ 2025-02-11  8:58 Lei Yu
  2025-02-12  1:42 ` Patrick Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Lei Yu @ 2025-02-11  8:58 UTC (permalink / raw)
  To: openbmc

This email describes a repo-ci issue on some repos related to
clang-tidy and requests for comments to fix this issue.
An example of such an issue is
https://jenkins.openbmc.org/job/ci-repository/100565/console

# Background

1. At first, openbmc-build-scripts uses `run-clang-tidy` to run and
fix the clang-tidy issues. This works ok.
   `run-clang-tidy` will parse the `compile_commands.json` and
**only** run clang-tidy on the specific files to be built.
2. Later, build-scripts changes it to run `ninja clang-tidy` [1]
    This effectively changes the files to run clang-tidy, that in
meson, it will use `git ls-files` and a suffix filter to filter all
the c/c++ like files to run clang-tidy.
    The benefit of this change is that it will run header files as
well, and potentially find more issues.
    However, it does not call "fix" and thus does not automatically
fix the issues found by clang-tidy.
3. Then meson introduces `clang-tidy-fix`, that does call
`run-clang-tidy -fix` internally, and thus it could "fix" the code.
build-scrtips is changed to call `clang-tidy-fix. [2]
    At this point, it introduces a side-effect that `run-clang-tidy`
will filter the files from the `compile_commands.json`, and the hpp
files will be filtered out.
4. Now with meson 1.7.0, it changes the internal `clang-tidy-fix`
behaviors, and it will check all the c/c++ like files again, with
`-fix` support.

# The issue

With the current meson calling "clang-tidy-fix", it introduces another
issue in that it runs **all** the c/c++ like files of the repo, even
if it's not configured to be compiled.

For example, `phosphor-debug-collector` has the
`openpower-dumps-extension` feature disabled by default, and its
`dump-extensions.cpp` includes `openpower_dumps_config.h` that is
generated when the feature is enabled. By default, it's missing, and
it gets a clang-tidy failure on checking this file.

# How to fix

I would like to ask how to fix such issues from OpenBMC's perspective.

Several potential options to discuss:
1. To fix meson's clang-tidy to run only files from `compile_commands.json`.
    Drawback: this way, it will not run clang-tidy on hpp files anymore.
2. Change back build-scripts to call `run-clang-tidy`. This is
effectively the same as option 1.
3. Keep current behavior, and avoid any repo that has a similar case
as `phosphor-debug-collector`.
(https://gerrit.openbmc.org/c/openbmc/phosphor-debug-collector/+/78065
does fix this from the repo)

[1]: https://github.com/openbmc/openbmc-build-scripts/commit/1eb1994bbcceb70d575458dc7a968c0f26b5b6e7
[2]: https://github.com/openbmc/openbmc-build-scripts/commit/ac9c9c7


--
BRs,
Lei YU

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-13 20:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11  8:58 About meson clang-tidy issue on some repos Lei Yu
2025-02-12  1:42 ` Patrick Williams
2025-02-12  6:23   ` Lei Yu
2025-02-13 20:07     ` Patrick Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.