Bug#819072: llvm-3.8-dev: LLVM CMake files broken by Debian packaging

Brad King brad.king at kitware.com
Thu Mar 24 18:43:07 UTC 2016


On 03/24/2016 11:42 AM, Sylvestre Ledru wrote:
>>     CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
>>       include could not find load file:
> As you are much more familiar than me on this, would you mind proposing a patch?

While I'm familiar with LLVM's CMake packaging infrastructure I'm not so
much with debian packaging.  I'm not set up to try building the package
myself but I can help you update

 https://anonscm.debian.org/viewvc/pkg-llvm/llvm-toolchain/branches/3.8/

as covered in the following sections.

----------------------------------------------------------------------------------

The `debian/patches/fix-cmake-config-prefix.diff` patch needs to be extended
to cover the CMake build system too.  I've attached the updated file.

That will fix LLVM_INSTALL_PREFIX and therefore everything LLVMConfig.cmake
computes relative to it (except LLVM_CMAKE_DIR, see below).

----------------------------------------------------------------------------------

In `debian/llvm-X.Y-dev.install.in` we have:

    # Explicit debian/tmp since there are multiple declarations
    debian/tmp/usr/lib/llvm- at LLVM_VERSION@/share/llvm/cmake/*.cmake usr/share/llvm- at LLVM_VERSION@/cmake/

This moves the CMake packaging files out of their original/intended location
under the install prefix and into a separate directory so they can be found
by default by find_package(LLVM) in CMake projects.  However, this approach
breaks a few things:

* LLVMConfig.cmake uses

      set(LLVM_CMAKE_DIR "${LLVM_INSTALL_PREFIX}/share/llvm/cmake")

  to compute the location of the CMake packaging files.  This is broken
  when they are moved.  Previously `debian/rules` accounted for this by
  fixing up LLVMConfig.cmake:

      # Change CMake module dir
      sed -i 's|LLVM_CMAKE_DIR "/usr/lib/llvm-$(LLVM_VERSION)/share/llvm/cmake"|LLVM_CMAKE_DIR "/usr/share/llvm-$(LLVM_VERSION)/cmake"|' $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/llvm/cmake/LLVMConfig.cmake

  This line does not work with the CMake-based build of LLVM because the
  content in LLVMConfig.cmake that it tries to update is now different.

* LLVMExports.cmake expects to find the LLVM library files (*.a, etc.)
  relative to its own location.  This is broken when it is moved.

One possible fix is to hack both of these files post-installation again.
This approach may require future maintenance as the content of the files
changes.  IMO instead we should do what I suggested in #785931 originally:
drop the relocation of the cmake directory and instead add a symlink

    /usr/share/llvm- at LLVM_VERSION@/cmake -> /usr/lib/llvm- at LLVM_VERSION@/share/llvm/cmake

That way the CMake packaging files can compute everything relative to
their own location.  The symlink will still allow find_package(LLVM)
to work out of the box.

----------------------------------------------------------------------------------

CMake's packaging files have checks to make sure the library files
it installed are all there.  After manually hacking my local system
to pretend the above changes were made to the packaging, I now get
this error:

    CMake Error at /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports.cmake:1034 (message):
      The imported target "PollyISL" references the file

         "/usr/lib/llvm-3.8/lib/libPollyISL.a"

      but this file does not exist.  Possible reasons include:

      * The file was deleted, renamed, or moved to another location.

      * An install or uninstall procedure did not complete successfully.

      * The installation package was faulty and contained

         "/usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports.cmake"

      but not all the files it references.

The reason for this is because `debian/rules` does:

    # Don't think it is used
    rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/libPolly*a

We either need to leave these files in place or teach `debian/rules` to
fix content in `LLVMExports-relwithdebinfo.cmake`:

    sed -i '/_IMPORT_CHECK_TARGETS Polly/ {s|^|#|}' $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/share/llvm/cmake/LLVMExports-*.cmake

This simply disables CMake's check that the Polly library files exist.

----------------------------------------------------------------------------------

After manually hacking my local system to pretend the above changes
were made to the packaging, I now get this error:

    CMake Error at /usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports.cmake:1034 (message):
      The imported target "LLVM" references the file

         "/usr/lib/llvm-3.8/lib/libLLVM-3.8.so.1"

      but this file does not exist.  Possible reasons include:

      * The file was deleted, renamed, or moved to another location.

      * An install or uninstall procedure did not complete successfully.

      * The installation package was faulty and contained

         "/usr/lib/llvm-3.8/share/llvm/cmake/LLVMExports.cmake"

      but not all the files it references.

The package moves this file to /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1
but does not add a symlink of that specific name back to the original
location.  It looks like similarly named symlinks are created:

    $ ls -d /usr/lib/llvm-3.8/lib/libLLVM-3.8*
    /usr/lib/llvm-3.8/lib/libLLVM-3.8.0.so@
    /usr/lib/llvm-3.8/lib/libLLVM-3.8.0.so.1@
    /usr/lib/llvm-3.8/lib/libLLVM-3.8.so@

but I do not see where.  Please add the missing link:

    /usr/lib/x86_64-linux-gnu/libLLVM-3.8.so.1@

With that I can find_package(LLVM) without error.

Thanks,
-Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-cmake-config-prefix.diff
Type: text/x-diff
Size: 2276 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20160324/c82ce82d/attachment-0001.diff>


More information about the Pkg-llvm-team mailing list