mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-07-24 05:25:31 +00:00
Make CMake find_package(Clang) work. Fixes upstream bug https://bugs.llvm.org/show_bug.cgi?id=37128
* 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.
This commit is contained in:
commit
44db7ce6bf
12
debian/changelog
vendored
12
debian/changelog
vendored
@ -2,6 +2,18 @@ llvm-toolchain-6.0 (1:6.0.1~+rc1-1~exp2) experimental; urgency=medium
|
||||
|
||||
* Add python-yaml as dep for clang-tidy (Closes: #890514)
|
||||
|
||||
[ Peter Wu ]
|
||||
* 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.
|
||||
|
||||
-- Sylvestre Ledru <sylvestre@debian.org> Mon, 07 May 2018 23:27:26 +0200
|
||||
|
||||
llvm-toolchain-6.0 (1:6.0.1~+rc1-1~exp1) experimental; urgency=medium
|
||||
|
2
debian/clang-X.Y.install.in
vendored
2
debian/clang-X.Y.install.in
vendored
@ -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@
|
||||
|
2
debian/clang-X.Y.links.in
vendored
Normal file
2
debian/clang-X.Y.links.in
vendored
Normal file
@ -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@
|
34
debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch
vendored
Normal file
34
debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
From d0d969074f6e0f975ad53d21e7ce6c7b40cf2957 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Wu <peter@lekensteyn.nl>
|
||||
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
|
||||
|
34
debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch
vendored
Normal file
34
debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
From c830d84bc802ca1e9219415a5784c4ad97a34819 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Wu <peter@lekensteyn.nl>
|
||||
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
|
||||
|
27
debian/patches/fix-cmake-config-prefix.diff
vendored
27
debian/patches/fix-cmake-config-prefix.diff
vendored
@ -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}")
|
3
debian/patches/series
vendored
3
debian/patches/series
vendored
@ -26,7 +26,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
|
||||
|
70
debian/qualify-clang.sh
vendored
70
debian/qualify-clang.sh
vendored
@ -26,18 +26,18 @@ fi
|
||||
echo 'int main() {return 0;}' > foo.c
|
||||
clang-$VERSION foo.c
|
||||
|
||||
echo '#include <stddef.h>' > x.c
|
||||
clang-$VERSION -c x.c
|
||||
echo '#include <stddef.h>' > foo.c
|
||||
clang-$VERSION -c foo.c
|
||||
|
||||
echo "#include <fenv.h>" > x.cc
|
||||
NBLINES=$(clang++-$VERSION -P -E x.cc|wc -l)
|
||||
echo "#include <fenv.h>" > foo.cc
|
||||
NBLINES=$(clang++-$VERSION -P -E foo.cc|wc -l)
|
||||
if test $NBLINES -lt 100; then
|
||||
echo "Error: more than 100 lines should be returned"
|
||||
exit 42
|
||||
fi
|
||||
|
||||
echo '#include <emmintrin.h>' > x.cc
|
||||
clang++-$VERSION -c x.cc
|
||||
echo '#include <emmintrin.h>' > foo.cc
|
||||
clang++-$VERSION -c foo.cc
|
||||
|
||||
echo '
|
||||
#include <string.h>
|
||||
@ -46,16 +46,16 @@ main ()
|
||||
{
|
||||
(void) strcat;
|
||||
return 0;
|
||||
}' > x.c
|
||||
clang-$VERSION -c x.c
|
||||
}' > foo.c
|
||||
clang-$VERSION -c foo.c
|
||||
|
||||
echo '#include <errno.h>
|
||||
int main() {} ' > x.c
|
||||
clang-$VERSION x.c
|
||||
int main() {} ' > foo.c
|
||||
clang-$VERSION foo.c
|
||||
|
||||
echo '#include <chrono>
|
||||
int main() { }' > x.cpp
|
||||
clang++-$VERSION -std=c++11 x.cpp
|
||||
int main() { }' > foo.cpp
|
||||
clang++-$VERSION -std=c++11 foo.cpp
|
||||
|
||||
echo '#include <stdio.h>
|
||||
int main() {
|
||||
@ -166,20 +166,45 @@ int main (void)
|
||||
{ std::vector<int> a;
|
||||
a.push_back (0);
|
||||
}
|
||||
' > o.cpp
|
||||
clang++-$VERSION -g -o o o.cpp
|
||||
echo 'target create "./o"
|
||||
' > foo.cpp
|
||||
clang++-$VERSION -g -o foo foo.cpp
|
||||
echo 'target create "./foo"
|
||||
b main
|
||||
r
|
||||
n
|
||||
p a
|
||||
quit' > lldb-cmd.txt
|
||||
lldb-$VERSION -s lldb-cmd.txt ./o
|
||||
lldb-$VERSION -s lldb-cmd.txt ./foo
|
||||
|
||||
echo "int main() { return 1; }" > foo.c
|
||||
clang-$VERSION -fsanitize=efficiency-working-set -o foo foo.c
|
||||
./foo > /dev/null || true
|
||||
|
||||
|
||||
rm -rf cmaketest && mkdir cmaketest
|
||||
cat > cmaketest/CMakeLists.txt <<EOF
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(SanityCheck)
|
||||
find_package(LLVM $VERSION REQUIRED CONFIG)
|
||||
message(STATUS "LLVM_CMAKE_DIR: \${LLVM_CMAKE_DIR}")
|
||||
if(NOT EXISTS "\${LLVM_TOOLS_BINARY_DIR}/clang")
|
||||
message(FATAL_ERROR "Invalid LLVM_TOOLS_BINARY_DIR: \${LLVM_TOOLS_BINARY_DIR}")
|
||||
endif()
|
||||
# TODO add version to ClangConfig.cmake and use $VERSION below
|
||||
find_package(Clang REQUIRED CONFIG)
|
||||
find_file(H clang/AST/ASTConsumer.h PATHS \${CLANG_INCLUDE_DIRS} NO_DEFAULT_PATH)
|
||||
message(STATUS "CLANG_INCLUDE_DIRS: \${CLANG_INCLUDE_DIRS}")
|
||||
if(NOT H)
|
||||
message(FATAL_ERROR "Invalid Clang header path: \${CLANG_INCLUDE_DIRS}")
|
||||
endif()
|
||||
EOF
|
||||
mkdir cmaketest/standard cmaketest/explicit
|
||||
echo "Test: CMake find LLVM and Clang in default path"
|
||||
(cd cmaketest/standard && CC=clang-$VERSION CXX=clang++-$VERSION cmake ..)
|
||||
echo "Test: CMake find LLVM and Clang in explicit prefix path"
|
||||
(cd cmaketest/explicit && CC=clang-$VERSION CXX=clang++-$VERSION CMAKE_PREFIX_PATH=/usr/lib/llvm-$VERSION cmake ..)
|
||||
rm -rf cmaketest
|
||||
|
||||
CLANG=clang-$VERSION
|
||||
#command -v "$CLANG" 1>/dev/null 2>/dev/null || { printf "Usage:\n%s CLANGEXE [ARGS]\n" "$0" 1>&2; exit 1; }
|
||||
#shift
|
||||
@ -214,6 +239,9 @@ int main ()
|
||||
}
|
||||
EOF
|
||||
|
||||
#clean up
|
||||
rm a.out bar crash-* foo foo.* lldb-cmd.txt main.c test_fuzzer.cc
|
||||
|
||||
# only for AMD64 for now
|
||||
# many sanitizers only work on AMD64
|
||||
# x32 programs need to be enabled in the kernel bootparams for debian
|
||||
@ -222,6 +250,8 @@ EOF
|
||||
# SYSTEM should iterate multiple targets (eg. x86_64-unknown-none-gnu for embedded)
|
||||
# MARCH should iterate the library architectures via flags
|
||||
# LIB should iterate the different libraries
|
||||
echo "if it fails, please run"
|
||||
echo "apt-get install libc6-dev:i386 libgcc-5-dev:i386 libc6-dev-x32 libx32gcc-5-dev"
|
||||
for SYSTEM in ""; do
|
||||
for MARCH in -m64 -m32 -mx32 "-m32 -march=i686"; do
|
||||
for LIB in --rtlib=compiler-rt -fsanitize=address -fsanitize=thread -fsanitize=memory -fsanitize=undefined -fsanitize=dataflow; do # -fsanitize=efficiency-working-set; do
|
||||
@ -246,8 +276,14 @@ for SYSTEM in ""; do
|
||||
done
|
||||
done
|
||||
|
||||
echo "If the following fails, try setting an environment variable such as:"
|
||||
echo "OBJC_INCLUDE_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/include"
|
||||
echo "#include <objc/objc.h>" > foo.m
|
||||
clang-$VERSION -c foo.m
|
||||
|
||||
echo "Completed"
|
||||
if test ! -f /usr/lib/llvm-$VERSION/lib/libclangBasic.a; then
|
||||
echo "Install libclang-$VERSION-dev"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Completed"
|
||||
|
6
debian/rules
vendored
6
debian/rules
vendored
@ -443,12 +443,12 @@ endif
|
||||
# Remove some license files
|
||||
rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/include/llvm/Support/LICENSE.TXT
|
||||
|
||||
# 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)/lib/cmake/llvm/LLVMConfig.cmake
|
||||
|
||||
# Disable CMake's package validation checks for target files that we may remove.
|
||||
sed -i '/_IMPORT_CHECK_TARGETS \(Polly\|sancov\)/ {s|^|#|}' $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/llvm/LLVMExports-*.cmake
|
||||
|
||||
# Disable CMake's package validation checks for binaries that may not be installed
|
||||
sed -i 's|.*_IMPORT_CHECK_FILES_FOR_.*/bin/.*)|#&|' $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/cmake/clang/ClangTargets-*.cmake
|
||||
|
||||
# Managed in python-lldb-X.Y.links.in
|
||||
rm -f $(DEB_INST)/usr/lib/llvm-$(LLVM_VERSION)/lib/python*/site-packages/lldb/_lldb.so
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user