diff --git a/debian/changelog b/debian/changelog index cd5b7036..906adee7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +llvm-toolchain-5.0 (1:5.0.2~svn328729-1~exp1) UNRELEASED; urgency=medium + + * Make CMake find_package(Clang) work. Fixes upstream bug + https://bugs.llvm.org/show_bug.cgi?id=37128 + - Move Clang*.cmake back to /usr/lib/llvm-X.Y/lib/cmake/clang and install a + symlink in /usr/lib/cmake/clang-X.Y. + - Ensure that the LLVM installation prefix is correctly discovered despire + symlinks (replaces fix-cmake-config-prefix.diff). + - Create /usr/lib/llvm-X.Y/bin/clang-X.Y symlink as required by + ClangTargets-relwithdebinfo.cmake. + - Remove useless LLVM_CMAKE_DIR sed command that did not match anything. + - Ignore missing binaries in ClangTargets-relwithdebinfo.cmake. + + -- Peter Wu Sun, 06 May 2018 17:42:16 +0200 + llvm-toolchain-5.0 (1:5.0.2-1) unstable; urgency=medium * New stable release (Spectre Mitigation) diff --git a/debian/clang-X.Y.install.in b/debian/clang-X.Y.install.in index 20dbf6cc..1d1907c2 100644 --- a/debian/clang-X.Y.install.in +++ b/debian/clang-X.Y.install.in @@ -3,7 +3,7 @@ usr/lib/llvm-@LLVM_VERSION@/bin/clang++ usr/lib/llvm-@LLVM_VERSION@/bin/clang-cpp #usr/share/man/man1/clang.1 usr/share/man/man1/ -usr/lib/llvm-@LLVM_VERSION@/lib/cmake/clang/*.cmake usr/share/llvm-@LLVM_VERSION@/cmake/ +usr/lib/llvm-@LLVM_VERSION@/lib/cmake/clang/*.cmake usr/lib/llvm-@LLVM_VERSION@/share/clang/bash-autocomplete.sh usr/bin/clang-@LLVM_VERSION@ diff --git a/debian/clang-X.Y.links.in b/debian/clang-X.Y.links.in new file mode 100644 index 00000000..4ba8a3b9 --- /dev/null +++ b/debian/clang-X.Y.links.in @@ -0,0 +1,2 @@ +usr/lib/llvm-@LLVM_VERSION@/bin/clang usr/lib/llvm-@LLVM_VERSION@/bin/clang-@LLVM_VERSION@ +usr/lib/llvm-@LLVM_VERSION@/lib/cmake/clang usr/lib/cmake/clang-@LLVM_VERSION@ diff --git a/debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch b/debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch new file mode 100644 index 00000000..1aa87919 --- /dev/null +++ b/debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch @@ -0,0 +1,34 @@ +From d0d969074f6e0f975ad53d21e7ce6c7b40cf2957 Mon Sep 17 00:00:00 2001 +From: Peter Wu +Date: Fri, 4 May 2018 15:43:06 +0200 +Subject: [PATCH] [llvm] cmake: resolve symlinks in LLVMConfig.cmake + +Ensure that symlinks such as /usr/lib/llvm-X.Y/cmake (pointing to +lib/cmake/llvm) are resolved. This ensures that LLVM_INSTALL_PREFIX +becomes /usr/lib/llvm-X.Y instead of /usr. + +Partially addresses PR37128 +--- + cmake/modules/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt +index 6074e835859..1cf4569b884 100644 +--- a/cmake/modules/CMakeLists.txt ++++ b/cmake/modules/CMakeLists.txt +@@ -76,10 +76,10 @@ file(COPY . + # Generate LLVMConfig.cmake for the install tree. + set(LLVM_CONFIG_CODE " + # Compute the installation prefix from this LLVMConfig.cmake file location. +-get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") ++get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" REALPATH)") + # Construct the proper number of get_filename_component(... PATH) + # calls to compute the installation prefix. +-string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}") ++string(REGEX REPLACE "/" ";" _count "prefix/${LLVM_INSTALL_PACKAGE_DIR}") + foreach(p ${_count}) + set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE} + get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)") +-- +2.17.0 + diff --git a/debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch b/debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch new file mode 100644 index 00000000..dca84e36 --- /dev/null +++ b/debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch @@ -0,0 +1,34 @@ +From c830d84bc802ca1e9219415a5784c4ad97a34819 Mon Sep 17 00:00:00 2001 +From: Peter Wu +Date: Fri, 4 May 2018 15:55:26 +0200 +Subject: [PATCH] [clang] cmake: resolve symlinks in ClangConfig.cmake + +Ensure that symlinks such as /usr/lib/cmake/clang-X.Y (pointing to +/usr/lib/llvm-X.Y/lib/cmake/llvm) are resolved. This ensures that +CLANG_INSTALL_PREFIX ends up to be /usr/lib/llvm-X.Y instead of /usr. + +Partially addresses PR37128 +--- + cmake/modules/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt +index be6d1d7257..bcb61f6cc8 100644 +--- a/clang/cmake/modules/CMakeLists.txt ++++ b/clang/cmake/modules/CMakeLists.txt +@@ -30,10 +30,10 @@ set(CLANG_CONFIG_EXPORTS_FILE) + # Generate ClangConfig.cmake for the install tree. + set(CLANG_CONFIG_CODE " + # Compute the installation prefix from this LLVMConfig.cmake file location. +-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") ++get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" REALPATH)") + # Construct the proper number of get_filename_component(... PATH) + # calls to compute the installation prefix. +-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}") ++string(REGEX REPLACE "/" ";" _count "prefix/${CLANG_INSTALL_PACKAGE_DIR}") + foreach(p ${_count}) + set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE} + get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)") +-- +2.17.0 + diff --git a/debian/patches/fix-cmake-config-prefix.diff b/debian/patches/fix-cmake-config-prefix.diff deleted file mode 100644 index 2587d106..00000000 --- a/debian/patches/fix-cmake-config-prefix.diff +++ /dev/null @@ -1,27 +0,0 @@ -## Description: add some description -## Origin/Author: add some origin or author -## Bug: bug URL ---- -# cmake/modules/CMakeLists.txt | 11 +---------- -# 1 file changed, 1 insertion(+), 10 deletions(-) -# ---- a/cmake/modules/CMakeLists.txt -+++ b/cmake/modules/CMakeLists.txt -@@ -74,16 +74,7 @@ file(COPY . - ) - - # Generate LLVMConfig.cmake for the install tree. --set(LLVM_CONFIG_CODE " --# Compute the installation prefix from this LLVMConfig.cmake file location. --get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") --# Construct the proper number of get_filename_component(... PATH) --# calls to compute the installation prefix. --string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}") --foreach(p ${_count}) -- set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE} --get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)") --endforeach(p) -+set(LLVM_CONFIG_CODE "set(LLVM_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") - set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include") - set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") - set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") diff --git a/debian/patches/series b/debian/patches/series index 42b2d521..6fb81167 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -28,7 +28,8 @@ clang-analyzer-force-version.diff install-scan-build-py.diff scan-view-fix-path.diff mips-fpxx-enable.diff -fix-cmake-config-prefix.diff +0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch +0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch lldb-link-atomic-cmake.patch disable-source-interleave.diff silent-gold-utils.diff diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index a561dddf..8caa9ccb 100644 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -246,5 +246,29 @@ done echo "#include " > foo.m clang-$VERSION -c foo.m +if test ! -f /usr/lib/llvm-$VERSION/lib/libclangBasic.a; then + echo "Install libclang-$VERSION-dev" + exit 1 +fi + +rm -rf cmaketest && mkdir cmaketest +cat > cmaketest/CMakeLists.txt <