Skip to content

Unable to use LLVM 16 as a library from apt.llvm.org #58075

@rymiel

Description

@rymiel

Installing the llvm-dev package for LLVM 16 from apt.llvm.org, then attempting to use LLVM as a CMake library using find_package(LLVM 16 REQUIRED CONFIG) always fails with the following error:

CMake Error at /usr/lib/llvm-16/lib/cmake/llvm/LLVMExports.cmake:1649 (message):
  The imported target "clangdRemoteIndexProto" references the file
     "/usr/lib/llvm-16/lib/libclangdRemoteIndexProto.a"
  but this file does not exist.  Possible reasons include:
  * The file was deleted, renamed, or moved to another location.

I don't have enough cmake knowledge to be sure of the cause, but i assume this to be caused by (or related to) https://reviews.llvm.org/D131593.
Since that changed generate_protos to call add_llvm_library, and generate_protos is used by https://github.com/llvm/llvm-project/blob/894c0e94f9c62413feef88fd577c430839abaea7/clang-tools-extra/clangd/index/remote/CMakeLists.txt, those now appear in the LLVM_AVAILABLE_LIBS list in /lib/cmake/llvm/LLVMConfig.cmake.
This can be manually verified by the existence of those entries in the cmake file, which were not there in previous versions.

Note that installing clangd alongside LLVM also fails, presumably because the LLVM cmake config is looking for packages under /usr/lib/llvm-16/, but clangd is installed somewhere else.

I am using ubuntu-22.04 (jammy) in GitHub actions (of which I can provide the build file in case further reproduction is required), but I was able to note the existence of clangd entries in the LLVM config for other distributions as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cmakeBuild system in general and CMake in particular

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions