Bug 506763

Summary: Undefined symbols builing clazy on MacOS with llvm20
Product: [Developer tools] clazy Reporter: Steve Skutnik <skutnikse>
Component: generalAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED FIXED    
Severity: normal CC: alexander.lohnau, smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Steve Skutnik 2025-07-08 14:19:51 UTC
SUMMARY

I am getting an undefined symbol error during the linking phase when building clazy from source on MacOS Sequoia 15.5 (Intel processor), using llvm v20.1.7 + clang v20.1.7. I am compiling from source off of the master branch at https://invent.kde.org/sdk/clazy.

STEPS TO REPRODUCE
1. Configure clazy using CMake & NInja:

  $ export CXX=clang++
  $ export LLVM_ROOT=/usr/local/opt/llvm
  $ cmake -G Ninja

2. Attempt to build:

  $ cmake --build .

3. Target builds but fails on linker stage.

OBSERVED RESULT

Undefined symbols for architecture x86_64:
  "llvm::Registry<clang::tidy::ClangTidyModule>::node::node(llvm::SimpleRegistryEntry<clang::tidy::ClangTidyModule> const&)", referenced from:
      llvm::Registry<clang::tidy::ClangTidyModule>::Add<ClazyModule>::Add(llvm::StringRef, llvm::StringRef) in ClazyClangTidyModule.cpp.o
  "llvm::Registry<clang::tidy::ClangTidyModule>::add_node(llvm::Registry<clang::tidy::ClangTidyModule>::node*)", referenced from:
      llvm::Registry<clang::tidy::ClangTidyModule>::Add<ClazyModule>::Add(llvm::StringRef, llvm::StringRef) in ClazyClangTidyModule.cpp.o
  "clang::tidy::ClangTidyCheck::run(clang::ast_matchers::MatchFinder::MatchResult const&)", referenced from:
      vtable for ClazyCheck in ClazyClangTidyModule.cpp.o
  "clang::tidy::ClangTidyCheck::ClangTidyCheck(llvm::StringRef, clang::tidy::ClangTidyContext*)", referenced from:
      ClazyCheck::ClazyCheck(llvm::StringRef, clang::tidy::ClangTidyContext*) in ClazyClangTidyModule.cpp.o
  "clang::tidy::ClangTidyModule::getModuleOptions()", referenced from:
      vtable for ClazyModule in ClazyClangTidyModule.cpp.o
  "clang::tidy::ClangTidyContext::diag(llvm::StringRef, clang::SourceLocation, llvm::StringRef, clang::DiagnosticIDs::Level)", referenced from:
      ClazyCheck::emitDiagnostic::'lambda'(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, clang::SourceLocation const&, clang::DiagnosticIDs::Level, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::vector<clang::FixItHint, std::__1::allocator<clang::FixItHint>> const&)::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, clang::SourceLocation const&, clang::DiagnosticIDs::Level, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::vector<clang::FixItHint, std::__1::allocator<clang::FixItHint>> const&) const in ClazyClangTidyModule.cpp.o
  "clang::tidy::ClangTidyCheckFactories::registerCheckFactory(llvm::StringRef, std::__1::function<std::__1::unique_ptr<clang::tidy::ClangTidyCheck, std::__1::default_delete<clang::tidy::ClangTidyCheck>> (llvm::StringRef, clang::tidy::ClangTidyContext*)>)", referenced from:
      void clang::tidy::ClangTidyCheckFactories::registerCheck<ClazyCheck>(llvm::StringRef) in ClazyClangTidyModule.cpp.o
  "vtable for clang::tidy::ClangTidyCheck", referenced from:
      clang::tidy::ClangTidyCheck::~ClangTidyCheck() in ClazyClangTidyModule.cpp.o
   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for clang::tidy::ClangTidyModule", referenced from:
      clang::tidy::ClangTidyModule::ClangTidyModule() in ClazyClangTidyModule.cpp.o
   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64

EXPECTED RESULT

clazy should link without errors.

SOFTWARE/OS VERSIONS
macOS: 15.5
Qt Version: N/A (testing for Qt5.15 => Qt6)

Linker command output (if it's useful):

ld: warning: ignoring duplicate libraries: '-lLLVM-20', '-lclangSupport', '-lclangTooling', '-lclangToolingCore', '-lclangToolingRefactoring', '/usr/local/Cellar/llvm/20.1.7/lib/libclangAPINotes.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangARCMigrate.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangASTMatchers.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangBasic.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangDependencyScanning.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangEdit.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangFrontendTool.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangLex.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangParse.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangSerialization.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangStaticAnalyzerCheckers.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangStaticAnalyzerCore.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangStaticAnalyzerFrontend.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangSupport.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangTooling.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangToolingCore.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangToolingInclusions.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangToolingRefactoring.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangToolingSyntax.a', '/usr/local/Cellar/llvm/20.1.7/lib/libclangTransformer.a'
Comment 1 Alexander Lohnau 2025-07-26 06:40:50 UTC
This is suprising to me - how did you aquite clang?

TO disable the clang-tidy plugin for now, add -DCLAZY_BUILD_CLANG_TIDY=OFF to the cmake parameters
Comment 2 Alexander Lohnau 2025-08-28 18:29:29 UTC
Okay, managed to get KDE CI to run into the same issue
Comment 3 Bug Janitor Service 2025-08-31 05:12:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/clazy/-/merge_requests/218
Comment 4 Alexander Lohnau 2025-08-31 05:16:56 UTC
Git commit 0fd4639c123322ccd036de20f2f7a63071456463 by Alexander Lohnau.
Committed on 31/08/2025 at 05:16.
Pushed by alex into branch 'master'.

Fix build on MacOS by explicitly including clangTidy lib

On linux, this dependency is implicitly provided.

M  +1    -0    cmake/FindClang.cmake

https://invent.kde.org/sdk/clazy/-/commit/0fd4639c123322ccd036de20f2f7a63071456463