I'm attempting to build my own RPM for clang-tidy with the llvm 12.0.1 release from github for legacy reasons. I'd like to just build clang-tidy without the rest of llvm keep it small. Currently I can only get it to work if I install everything in the llvm repo which ends up being quite large.
If I just install clang-tidy via make install-clang-tidy
it segfaults with this error when ran. I'm guessing that clang-tidy depends on something that I'm not building/installing but I don't know how to figure out what is missing.
I know about this question but following the steps in the top answer give me the same results.
clang-tidy: /home/developer/rpmbuild-debug/BUILD/llvm-project-llvmorg-12.0.1/clang/lib/AST/RecordLayoutBuilder.cpp:3194: const clang::ASTRecordLayout& clang::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const: Assertion `D && "Cannot get layout of forward declarations!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: clang-tidy -p=../build/compile_commands.json --extra-arg=-Wno-unknown-warning-option ./Tests/UnitTests/TrackFusion/ApplicationTest.cpp
1. <eof> parser at end of file
#0 0x00007fae68c04d5e (/lib64/libasan.so.6+0x45d5e)
#1 0x000000000a772850 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/clang-tidy+0xa772850)
#2 0x000000000a772bce PrintStackTraceSignalHandler(void*) (/usr/local/bin/clang-tidy+0xa772bce)
#3 0x000000000a76af38 llvm::sys::RunSignalHandlers() (/usr/local/bin/clang-tidy+0xa76af38)
#4 0x000000000a76c34a SignalHandler(int) (/usr/local/bin/clang-tidy+0xa76c34a)
#5 0x00007fae689b2630 __restore_rt (/lib64/libpthread.so.0+0xf630)
#6 0x00007fae677c9387 raise (/lib64/libc.so.6+0x36387)
#7 0x00007fae677caa78 abort (/lib64/libc.so.6+0x37a78)
#8 0x00007fae677c21a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
#9 0x00007fae677c2252 (/lib64/libc.so.6+0x2f252)
#10 0x000000000904989e clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/usr/local/bin/clang-tidy+0x904989e)
#11 0x000000000832928c clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/usr/local/bin/clang-tidy+0x832928c)
#12 0x000000000831028e clang::ASTContext::getTypeInfo(clang::Type const*) const (/usr/local/bin/clang-tidy+0x831028e)
#13 0x0000000008324f56 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/usr/local/bin/clang-tidy+0x8324f56)
#14 0x000000000831028e clang::ASTContext::getTypeInfo(clang::Type const*) const (/usr/local/bin/clang-tidy+0x831028e)
#15 0x0000000008328dfb clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/usr/local/bin/clang-tidy+0x8328dfb)
#16 0x000000000831028e clang::ASTContext::getTypeInfo(clang::Type const*) const (/usr/local/bin/clang-tidy+0x831028e)
#17 0x000000000064ec2d clang::tidy::altera::StructPackAlignCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/local/bin/clang-tidy+0x64ec2d)
#18 0x000000000299a884 clang::tidy::ClangTidyCheck::run(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/local/bin/clang-tidy+0x299a884)
#19 0x00000000080f53f4 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) (/usr/local/bin/clang-tidy+0x80f53f4)
#20 0x0000000008214b4b clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/local/bin/clang-tidy+0x8214b4b)
#21 0x00000000080f8508 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) (/usr/local/bin/clang-tidy+0x80f8508)
#22 0x0000000008187ea2 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) (/usr/local/bin/clang-tidy+0x8187ea2)
#23 0x000000000818a102 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (/usr/local/bin/clang-tidy+0x818a102)
#24 0x00000000081ea273 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseNamespaceDecl(clang::NamespaceDecl*) (/usr/local/bin/clang-tidy+0x81ea273)
#25 0x0000000008184407 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) (/usr/local/bin/clang-tidy+0x8184407)
#26 0x0000000008187ec9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) (/usr/local/bin/clang-tidy+0x8187ec9)
#27 0x000000000818a102 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (/usr/local/bin/clang-tidy+0x818a102)
#28 0x00000000081879b3 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDecl(clang::Decl*) (/usr/local/bin/clang-tidy+0x81879b3)
#29 0x0000000008187ec9 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) (/usr/local/bin/clang-tidy+0x8187ec9)
#30 0x00000000081893e5 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/local/bin/clang-tidy+0x81893e5)
#31 0x0000000008189ede clang::ast_matchers::internal::(anonymous namespace)::MatchASTConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/bin/clang-tidy+0x8189ede)
#32 0x00000000046a8c98 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/bin/clang-tidy+0x46a8c98)
#33 0x0000000004e39bcb clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/bin/clang-tidy+0x4e39bcb)
#34 0x00000000045cad7a clang::ASTFrontendAction::ExecuteAction() (/usr/local/bin/clang-tidy+0x45cad7a)
#35 0x00000000045d4910 clang::FrontendAction::Execute() (/usr/local/bin/clang-tidy+0x45d4910)
#36 0x00000000043e9d09 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/bin/clang-tidy+0x43e9d09)
#37 0x0000000002aa6d7d clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/local/bin/clang-tidy+0x2aa6d7d)
#38 0x000000000295d381 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::string>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/local/bin/clang-tidy+0x295d381)
#39 0x0000000002a8930b clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/local/bin/clang-tidy+0x2a8930b)
#40 0x0000000002a95a9a clang::tooling::ToolInvocation::run() (/usr/local/bin/clang-tidy+0x2a95a9a)
#41 0x0000000002aa0d97 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/local/bin/clang-tidy+0x2aa0d97)
#42 0x0000000002968e09 clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::string>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, llvm::StringRef) (/usr/local/bin/clang-tidy+0x2968e09)
#43 0x000000000042e5bf clang::tidy::clangTidyMain(int, char const**) (/usr/local/bin/clang-tidy+0x42e5bf)
#44 0x0000000000415bff main (/usr/local/bin/clang-tidy+0x415bff)
#45 0x00007fae677b5555 __libc_start_main (/lib64/libc.so.6+0x22555)
#46 0x0000000000415b44 _start (/usr/local/bin/clang-tidy+0x415b44)
Aborted