All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Williams <patrick@stwcx.xyz>
To: Lei Yu <yulei.sh@bytedance.com>
Cc: openbmc <openbmc@lists.ozlabs.org>
Subject: Re: About meson clang-tidy issue on some repos
Date: Tue, 11 Feb 2025 20:42:34 -0500	[thread overview]
Message-ID: <Z6v8ivnGwbt1QCDk@heinlein> (raw)
In-Reply-To: <CAGm54UHxNhSkzC84hS7fh_s-DpdOuii0g2O=GU4Z1aPQ6YMgKw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3320 bytes --]

On Tue, Feb 11, 2025 at 04:58:40PM +0800, Lei Yu wrote:
> 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.

Can we just fix the issues?  We merged the fix for the phosphor-debug-collector
one already today.

> 
> # 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.

I think we/you should discuss this issue upstream with Meson.  I'm also
surprised they made this change, not because of the hpp, but because of
dependency issues like the one I fixed in phosphor-debug-collector.

> 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)

How about we just fix them?  This should be a one-time effort, right?
> 
> [1]: https://github.com/openbmc/openbmc-build-scripts/commit/1eb1994bbcceb70d575458dc7a968c0f26b5b6e7
> [2]: https://github.com/openbmc/openbmc-build-scripts/commit/ac9c9c7
> 
> 
> --
> BRs,
> Lei YU

-- 
Patrick Williams

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-02-12  1:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11  8:58 About meson clang-tidy issue on some repos Lei Yu
2025-02-12  1:42 ` Patrick Williams [this message]
2025-02-12  6:23   ` Lei Yu
2025-02-13 20:07     ` Patrick Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z6v8ivnGwbt1QCDk@heinlein \
    --to=patrick@stwcx.xyz \
    --cc=openbmc@lists.ozlabs.org \
    --cc=yulei.sh@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.