Skip to content

Conversation

@IanWood1
Copy link
Contributor

When -DFUSILLI_ENABLE_CLANG_TIDY=ON is used outside the docker setup, builds failed with clang-tidy errors from Catch2. This occurred because CMAKE_CXX_CLANG_TIDY was set globally, causing clang-tidy to analyze all targets created after it was set, including third-party libraries added via FetchContent. CI builds worked because Catch2 was pre-installed in the Docker image, so it wasn't built from source and clang-tidy never ran on it.

Changes:

  • Instead of using global CMAKE_CXX_CLANG_TIDY, clang-tidy is now enabled explicitly on project-owned targets only using the CXX_CLANG_TIDY target property
  • Fixed fusilli_find_program(): Added check to prevent creating duplicate imported targets when called multiple times
  • Disabled llvm-header-guard check: This check was causing errors in sample files and the check is only really intended to work with LLVM. See [Fusilli] Add clang-tidy checks to CI nod-ai/amd-shark-ai#2607 (comment) for details.
  • Updated samples/layernorm/layernorm_utils.h and tests/hip_tests/hip_kernels.h to use consistent FUSILLI_ prefix.

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Copy link
Member

@sjain-stanford sjain-stanford left a comment

Choose a reason for hiding this comment

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

I did see this when building outside docker too (due to the Catch2 install like you mentioned). Glad you're fixing it.


set_target_properties(${target} PROPERTIES
CXX_CLANG_TIDY
"clang-tidy;-warnings-as-errors=*;--config-file=${PROJECT_SOURCE_DIR}/.clang-tidy"
Copy link
Member

Choose a reason for hiding this comment

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

nit: split one per line

Comment on lines +201 to +202
# Enable clang-tidy.
fusilli_enable_clang_tidy(libutils)
Copy link
Member

Choose a reason for hiding this comment

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

nit: move after target_link_libraries below

QUIET
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.11.0
SYSTEM
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment why we want this to be SYSTEM - is it to suppress warnings originating from Catch2?

)

# Enable clang-tidy.
fusilli_enable_clang_tidy(${_RULE_NAME})
Copy link
Member

Choose a reason for hiding this comment

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

This gets applied to add_fusilli_samples, add_fusilli_tests and add_fusilli_lit_test. What about add_fusilli_benchmark?

Comment on lines -7 to +8
#ifndef WORKSPACE_SAMPLES_LAYERNORM_LAYERNORM_UTILS_H
#define WORKSPACE_SAMPLES_LAYERNORM_LAYERNORM_UTILS_H
#ifndef FUSILLI_SAMPLES_LAYERNORM_LAYERNORM_UTILS_H
#define FUSILLI_SAMPLES_LAYERNORM_LAYERNORM_UTILS_H
Copy link
Member

Choose a reason for hiding this comment

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

I think I know why this was using WORKSPACE_ prefix: FUSILLI_ prefix is used for the library sources inside include/. For things outside, I'm fine using FUSILLI_ too as long as it's done consistently. Did llvm-header-guard have issues with one or the other?

-misc-no-recursion,
-misc-use-anonymous-namespace,
-llvm-else-after-return,
-llvm-header-guard,
Copy link
Member

Choose a reason for hiding this comment

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

Was the issue only for code outside include/fusilli/? If so, I wonder if there's a way to disable this only for targets other than libfusilli. Or just use the NOLINTNEXTLINE exclusion for the few guards outside libfusilli. This has been useful in catching header guard naming issues so want to see if we can keep it.

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.

2 participants