-
Notifications
You must be signed in to change notification settings - Fork 275
cmake: use {LLVM,Clang}Config.cmake #313
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
Conversation
Based on Daan De Meyer's #227
|
Looks like This sounds like a bug with Clang upstream. Why would the dependencies of the static library is a compile time configuration? This doesn't make sense to me. |
|
In nixpkgs we compile llvm with the following options We get the following linker errors for 0.20190314.1: As an example these are the symbols/references found for ASTFrontendAction in all libclang $ nm -gCA /nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/*.a | grep ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ARCMT.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ARCMT.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ARCMT.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ObjCMT.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ObjCMT.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangARCMigrate.a:ObjCMT.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangCodeGen.a:CodeGenAction.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangCodeGen.a:CodeGenAction.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangCodeGen.a:CodeGenAction.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangDaemon.a:ClangdUnit.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangDaemon.a:ClangdUnit.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangDoc.a:ClangDoc.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangDoc.a:ClangDoc.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangDoc.a:ClangDoc.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:ASTUnit.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:ASTUnit.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:ASTUnit.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:CompilerInstance.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendAction.cpp.o:0000000000000000 T clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendAction.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendAction.cpp.o:0000000000000000 V vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendActions.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendActions.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:FrontendActions.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:PrecompiledPreamble.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:PrecompiledPreamble.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangFrontend.a:PrecompiledPreamble.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIncludeFixer.a:IncludeFixer.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIncludeFixer.a:IncludeFixer.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIncludeFixerPlugin.a:IncludeFixerPlugin.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIncludeFixerPlugin.a:IncludeFixerPlugin.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIndex.a:IndexingAction.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIndex.a:IndexingAction.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangIndex.a:IndexingAction.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangMove.a:ClangMove.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangMove.a:ClangMove.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangMove.a:ClangMove.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangRewriteFrontend.a:FrontendActions.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangRewriteFrontend.a:FrontendActions.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangRewriteFrontend.a:FrontendActions.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangStaticAnalyzerFrontend.a:FrontendActions.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangStaticAnalyzerFrontend.a:FrontendActions.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangStaticAnalyzerFrontend.a:FrontendActions.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangStaticAnalyzerFrontend.a:ModelInjector.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidy.a:ClangTidy.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidy.a:ClangTidy.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidy.a:ClangTidy.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidyPlugin.a:ClangTidyPlugin.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidyPlugin.a:ClangTidyPlugin.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libclangTidyPlugin.a:ClangTidyPlugin.cpp.o: U vtable for clang::ASTFrontendAction
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libfindAllSymbols.a:FindAllSymbolsAction.cpp.o: U clang::ASTFrontendAction::ExecuteAction()
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libfindAllSymbols.a:FindAllSymbolsAction.cpp.o:0000000000000000 W clang::ASTFrontendAction::usesPreprocessorOnly() const
/nix/store/mvibpl88y47qiq0frmg8bk55jxzax1q1-clang-7.1.0/lib/libfindAllSymbols.a:FindAllSymbolsAction.cpp.o: U vtable for clang::ASTFrontendActioncc @dtzWill Any idea what is missing here? |
|
Solved by adding |
Based on Daan De Meyer's #227
Clang/LLVM dependencies
Before, we tracked clang and llvm dependencies manually. When they were provided as static libraries
*.a, we needed the full listing of usedllvm*clang*dependencies.After this change, we use
lib/cmake/llvm/LLVMConfig.cmakeandlib/cmake/clang/ClangConfig.cmake.When static libraries are linked,
ClangConfig.cmaketracks dependencies ofclang*viaINTERFACE_LINK_LIBRARIES:Only a small set of top-level dependencies need to be explicitly specified.
When shared libraries are linked, the dependency information for
clang*is not tracked. ccls' direct dependencies need to be explicitly specified. This list is longer than the case of static libraries.Include directories:
LLVM_ENABLE_RTTI
lib/cmake/llvm/LLVMConfig.cmakesets this variable. Users no longer have to specify it.We cannot use:
because it may wrongly sets
-fno-exceptions -fno-rtti. I believellvm_update_compile_flagsonly makes sense for llvm in-tree targets. ccls always enables exceptions (thus it doesn't followLLVM_ENABLE_EH), but its RTTI followsLLVM_ENABLE_RTTI.