Skip to content

[libc++][CMake] Adds option to disable clang-tidy. #95654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mordante
Copy link
Member

There have been some reports that always enabling clang-tidy (added in #90077) has some false positives in the detection. It would be good to fix these. This adds an escape hatch to disable the tests, which avoids blocking users with this issue.

There have been some reports that always enabling clang-tidy (added in
llvm#90077) has some false positives in the detection. It would be good to fix
these. This adds an escape hatch to disable the tests, which avoids
blocking users with this issue.
@mordante mordante requested a review from EricWF June 15, 2024 11:58
@mordante mordante requested a review from a team as a code owner June 15, 2024 11:58
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jun 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 15, 2024

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

There have been some reports that always enabling clang-tidy (added in #90077) has some false positives in the detection. It would be good to fix these. This adds an escape hatch to disable the tests, which avoids blocking users with this issue.


Full diff: https://github.com/llvm/llvm-project/pull/95654.diff

2 Files Affected:

  • (modified) libcxx/CMakeLists.txt (+4)
  • (modified) libcxx/test/tools/CMakeLists.txt (+4)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 4b927017f8c2a..9a35ff30114cd 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -60,6 +60,10 @@ option(LIBCXX_ENABLE_FILESYSTEM
    available on the platform. This includes things like most parts of <filesystem> and
    others like <fstream>" ON)
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
+option(LIBCXX_DISABLE_CLANG_TIDY_TESTS
+  "Disables test using the clang-tidy plugin. This option should only be used
+   when autodetection fails, please file a bug report so the autodetection can
+   be improved." OFF)
 set(LIBCXX_SUPPORTED_HARDENING_MODES none fast extensive debug)
 set(LIBCXX_HARDENING_MODE "none" CACHE STRING
   "Specify the default hardening mode to use. This mode will be used inside the
diff --git a/libcxx/test/tools/CMakeLists.txt b/libcxx/test/tools/CMakeLists.txt
index 6d99c53ad46d9..801e45521edb8 100644
--- a/libcxx/test/tools/CMakeLists.txt
+++ b/libcxx/test/tools/CMakeLists.txt
@@ -5,4 +5,8 @@ if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   message(STATUS "Clang-tidy tests are disabled due to non-clang based compiler.")
   return()
 endif()
+if(LIBCXX_DISABLE_CLANG_TIDY_TESTS)
+  message(STATUS "Clang-tidy tests are disabled by the configuration option LIBCXX_DISABLE_CLANG_TIDY_TESTS.")
+  return()
+endif()
 add_subdirectory(clang_tidy_checks)

Copy link
Member

@EricWF EricWF left a comment

Choose a reason for hiding this comment

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

Thanks!

Minor nit: I think LIBCXX_ENABLE_CLANG_TIDY_TESTS would be more idiomatic, but in either case, the option is really just meant as a last resort for when builds break.

@EricWF
Copy link
Member

EricWF commented Jun 16, 2024

On second thought, This setups allows for clang-tidy tests to be silently turned off if the auto-configuration fails, right?
I don't like when tests can turn themselves off silently and automagically, and I really like the clang-tidy tests.

If this is the case, should this option have three values? ON, FORCE_ON, and OFF? Where the default is ON , and is set to FORCE_ON in the CI?

@ldionne
Copy link
Member

ldionne commented Jun 17, 2024

@mordante Where have there been some reports of the clang-tidy detection not working properly? I have a preference for simplifying the configuration around this to the maximum.

@EricWF To prevent these mis-configuration issues, I think we could instead enforce the set of Lit features that is defined inside our CI builders. This would catch a mis-configuration of this kind but also many other similar issues, and it wouldn't require adding an option for this in the CMake.

@mordante
Copy link
Member Author

mordante commented Jul 5, 2024

This option is mainly intended as an escape hatch when auto detection fails. I still feel we should fix those issues; however at the moment when somebody encounters the situation they are blocked from testing libc++.

@ldionne
Copy link
Member

ldionne commented Nov 28, 2024

This option is mainly intended as an escape hatch when auto detection fails. I still feel we should fix those issues; however at the moment when somebody encounters the situation they are blocked from testing libc++.

IMO we should consider such failures as a priority and fix them -- we should aim for people not to disable these checks instead. That's the reason for my pushback on this patch. Also, since I don't know what the reports for clang-tidy not working were, I don't know what we're working around concretely. Do you still feel that this patch is worth pursuing?

@mordante
Copy link
Member Author

mordante commented Feb 9, 2025

I agree that we should abandon this.

@mordante mordante closed this Feb 9, 2025
@mordante mordante deleted the review/disable_clang-tidy branch February 9, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants