Skip to content

Conversation

ziuziakowska
Copy link

This replaces the existing ot-tidy.sh script with a new Python script.

This new script should make it easier to run the linter locally in the same way as CI, as the older wrapper script did not have any usage information.

The script also checks for some misconfigurations and reports those - such as QEMU not being configured to use Clang which results in a different incompatible set of warning flags to be used with GCC to be used for clang-tidy.

In addition, this script adds a -j flag to run linting in parallel, using the run-clang-tidy wrapper that comes with clang-tidy. On my machine, this reduced linting time on the same set of files as CI from ~3 minutes to 30 seconds.

Copy link

@jwnrt jwnrt left a comment

Choose a reason for hiding this comment

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

I get this error from the script:

$ scripts/opentitan/ot_tidy.py --ci-files
Could not parse 'clang-tidy' version string.

Here's my output of clang-tidy --version:

$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 16.0.2
  Optimized build.

I think it's because my version_line is the second line, not the first

@ziuziakowska
Copy link
Author

I think it's because my version_line is the second line, not the first

Fixed it to look for that on any line.
Mine appeared like this:

$ clang-tidy-20 --version
Ubuntu LLVM version 20.1.2
  Optimized build.

@jwnrt
Copy link

jwnrt commented Sep 23, 2025

Yep, that works now, thanks

Copy link

@rivos-eblot rivos-eblot left a comment

Choose a reason for hiding this comment

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

I think several features are broken, and some are a bit fragile (parsing, ANSI management, ...).

Can you run flake8, as there are many outsized lines and argument aligment warning messages. Thanks.

@ziuziakowska ziuziakowska changed the title New ot_tidy.py script for development and CI New ot-tidy.py script for development and CI Sep 24, 2025
Copy link

@AlexJones0 AlexJones0 left a comment

Choose a reason for hiding this comment

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

Thanks, I've left a couple of additional comments. This LGTM though and definitely makes local clang-tidy runs faster.

This script is intendde to replace the `ot-tidy.sh` script for running
clang-tidy on our part of the codebase.

A `-j` flag is added to run clang-tidy jobs in parallel, using the
run-clang-tidy script that comes with it. On my machine this speeds up
linting files for CI from >3 minutes to ~30 seconds.

The script also checks for some configuration issues, such as the C
compiler for QEMU not being set to clang - this causes some warnings
flags to be enabled that are recognised by GCC but not clang, and these
will show up as errors.

Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
Replaces all usages and updates docs.

Older `ot-tidy.sh` script is retained for any current users of it.

Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
@jwnrt
Copy link

jwnrt commented Oct 1, 2025

Regression failure is known and unrelated

@jwnrt jwnrt merged commit 8d98254 into lowRISC:ot-9.2.0 Oct 1, 2025
7 of 8 checks passed
@ziuziakowska ziuziakowska deleted the ot-tidy branch October 9, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants