-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove the requirement to link with clangTidy #72140
Remove the requirement to link with clangTidy #72140
Conversation
Seems to be working fine (CI run). So I will mark this as a draft to avoid it getting merged accidentally while I wait to hear from @BrettDong on what inspired the change. |
I got a huge number of "undefined references" linking error when building the plugin locally on my macOS system. The compiler used is Apple Clang from Xcode, and the LLVM library is installed from Homebrew package manager. |
Had you previously built successfully on the same system against LLVM 16? |
Building with LLVM 16 was successful but linking error occurs with LLVM 17. |
A portable way to create our plugin target in CMake is probably to use |
I also did some poking around, I wonder if we might be able to work around the issue using This is based on some other GitHub issues. See, for example, this comment and this PR. If this is the issue, though, I'm not sure it explains why LLVM 16 worked but 17 doesn't. |
I can successfully build and load the plugin in clang-tidy 17 on macOS with this patch diff --git a/tools/clang-tidy-plugin/CMakeLists.txt b/tools/clang-tidy-plugin/CMakeLists.txt
index 46f3021206..4d5f5e35fb 100644
--- a/tools/clang-tidy-plugin/CMakeLists.txt
+++ b/tools/clang-tidy-plugin/CMakeLists.txt
@@ -55,7 +55,9 @@ if (CATA_CLANG_TIDY_EXECUTABLE)
else ()
set(CataAnalyzerName CataAnalyzerPlugin)
add_library(${CataAnalyzerName} MODULE ${CataAnalyzerSrc})
- target_link_libraries(${CataAnalyzerName} PRIVATE clangTidy)
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+ target_link_options(${CataAnalyzerName} PRIVATE -undefined dynamic_lookup)
+ endif ()
endif ()
target_include_directories(${CataAnalyzerName} SYSTEM PRIVATE |
Awesome. I'll update this PR accordingly. |
This was added as part of the transition to LLVM 17, but it breaks the build against LLVM 17 for me locally. The fix was needed for the macOS build, but we've now found an alternative solution to that. See CleverRaven#72140 for details.
881e3cf
to
fbad490
Compare
Summary
None
Purpose of change
A requirement to link against
clangTidy
was added as part of the transition to LLVM 17 (#71429), but it breaks the build against LLVM 17 for me locally.Describe the solution
After some discussion below, it seems like @BrettDong and I have found an alternative solution that works for both of us. I've updated this PR accordingly.
This has to do with a difference between the default linking behaviour on Linux and macOS.
Describe alternatives you've considered
Testing
This is the test.
Additional context