From 8f254c81fec7e0b569b42dabea14033cc5b4976f Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 27 Apr 2018 08:58:50 +0200 Subject: [PATCH 01/10] Fix a typo in the llvm automation --- debian/tests/llvm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/tests/llvm b/debian/tests/llvm index c1a74d4e..64b45735 100644 --- a/debian/tests/llvm +++ b/debian/tests/llvm @@ -5,5 +5,5 @@ if grep -q "Unexpected Failure" check-llvm_build_log.txt; then exit 1 else echo "build OK" -f1 +fi rm check-llvm_build_log.txt From c5c92b4a71a2dc4588753472f33eeccf83d36b60 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 27 Apr 2018 20:33:36 +0200 Subject: [PATCH 02/10] disable the tests for now --- debian/{tests => tests.disabled}/control | 0 debian/{tests => tests.disabled}/llvm | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename debian/{tests => tests.disabled}/control (100%) rename debian/{tests => tests.disabled}/llvm (100%) diff --git a/debian/tests/control b/debian/tests.disabled/control similarity index 100% rename from debian/tests/control rename to debian/tests.disabled/control diff --git a/debian/tests/llvm b/debian/tests.disabled/llvm similarity index 100% rename from debian/tests/llvm rename to debian/tests.disabled/llvm From 464aae317156a3a763f860761d783a4cee50ee88 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 6 May 2018 12:32:05 +0200 Subject: [PATCH 03/10] New stable release (Spectre Mitigation) AFAIK, only clang has been changed --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index c643dbb6..cd5b7036 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +llvm-toolchain-5.0 (1:5.0.2-1) unstable; urgency=medium + + * New stable release (Spectre Mitigation) + AFAIK, only clang has been changed + + -- Sylvestre Ledru Sun, 06 May 2018 10:56:14 +0200 + llvm-toolchain-5.0 (1:5.0.2~+rc1-1~exp2) experimental; urgency=medium * Remove the info text from the manpages (Closes: #894734) From 8ab8cd7b37077e2c615cb6cf031806edb62a2659 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 4 May 2018 16:21:08 +0200 Subject: [PATCH 04/10] Make Clang cmake files more usable * Move Clang*.cmake back to /usr/lib/llvm-X.Y/lib/cmake/clang and install a symlink in /usr/lib/cmake/clang-X.Y to ensure that CMake can still find it. * 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-6.0 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. * Add regression test to qualify-clang.sh. --- debian/clang-X.Y.install.in | 2 +- debian/clang-X.Y.links.in | 2 ++ ...resolve-symlinks-in-LLVMConfig.cmake.patch | 34 +++++++++++++++++++ ...esolve-symlinks-in-ClangConfig.cmake.patch | 34 +++++++++++++++++++ debian/patches/fix-cmake-config-prefix.diff | 27 --------------- debian/patches/series | 3 +- debian/qualify-clang.sh | 24 +++++++++++++ debian/rules | 6 ++-- 8 files changed, 100 insertions(+), 32 deletions(-) create mode 100644 debian/clang-X.Y.links.in create mode 100644 debian/patches/0001-llvm-cmake-resolve-symlinks-in-LLVMConfig.cmake.patch create mode 100644 debian/patches/0001-tools-clang-cmake-resolve-symlinks-in-ClangConfig.cmake.patch delete mode 100644 debian/patches/fix-cmake-config-prefix.diff 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 < Date: Mon, 7 May 2018 00:06:42 +0200 Subject: [PATCH 05/10] Update changelog with CMake fixes --- debian/changelog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/debian/changelog b/debian/changelog index c643dbb6..29fc1c17 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~+rc1-1~exp2) experimental; urgency=medium * Remove the info text from the manpages (Closes: #894734) From fa18d05b0d4d2d6a368a99c4bf96e4643cdb1c73 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 7 May 2018 22:13:37 +0200 Subject: [PATCH 06/10] Add a list of packages to install. Thanks to Peter Wu --- debian/qualify-clang.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 8caa9ccb..6a98e733 100644 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -219,6 +219,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 From d8c085e89cbc766b7be299cbb890454299e23a36 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 7 May 2018 22:13:55 +0200 Subject: [PATCH 07/10] Move the cmake check above --- debian/qualify-clang.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 6a98e733..34a277c6 100644 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -177,6 +177,27 @@ 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 </dev/null 2>/dev/null || { printf "Usage:\n%s CLANGEXE [ARGS]\n" "$0" 1>&2; exit 1; } #shift @@ -253,24 +274,4 @@ if test ! -f /usr/lib/llvm-$VERSION/lib/libclangBasic.a; then exit 1 fi -rm -rf cmaketest && mkdir cmaketest -cat > cmaketest/CMakeLists.txt < Date: Mon, 7 May 2018 22:16:34 +0200 Subject: [PATCH 08/10] prepare for upload --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 906adee7..095670ff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -llvm-toolchain-5.0 (1:5.0.2~svn328729-1~exp1) UNRELEASED; urgency=medium +llvm-toolchain-5.0 (1:5.0.2-2) unstable; urgency=medium * Make CMake find_package(Clang) work. Fixes upstream bug https://bugs.llvm.org/show_bug.cgi?id=37128 From ff7cf7d85a480ca866dacf3b1f724a37e9a99437 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 7 May 2018 14:05:04 +0200 Subject: [PATCH 09/10] qualify-clang: improve CMake test * Explicitly check that both the default CMake find_package and the explicit version-specific check works as intended. * Set CC/CXX to avoid requiring an additional compiler to be installed. * Add comment to workaround objc test failure on Ubuntu 14.04 and 16.04. --- debian/qualify-clang.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 34a277c6..ee9e70eb 100644 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -195,8 +195,11 @@ if(NOT H) message(FATAL_ERROR "Invalid Clang header path: \${CLANG_INCLUDE_DIRS}") endif() EOF -(cd cmaketest && cmake .) -rm -rf cmaketest +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 ..) CLANG=clang-$VERSION #command -v "$CLANG" 1>/dev/null 2>/dev/null || { printf "Usage:\n%s CLANGEXE [ARGS]\n" "$0" 1>&2; exit 1; } @@ -266,6 +269,8 @@ 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 " > foo.m clang-$VERSION -c foo.m From f4d8f7217e1d5d52f0f9daa8c0ce3bdf7d483c8a Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 8 May 2018 12:22:44 +0200 Subject: [PATCH 10/10] clean up every thing after launching the tests --- debian/qualify-clang.sh | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index ee9e70eb..1459d2e7 100644 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -26,18 +26,18 @@ fi echo 'int main() {return 0;}' > foo.c clang-$VERSION foo.c -echo '#include ' > x.c -clang-$VERSION -c x.c +echo '#include ' > foo.c +clang-$VERSION -c foo.c -echo "#include " > x.cc -NBLINES=$(clang++-$VERSION -P -E x.cc|wc -l) +echo "#include " > 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 ' > x.cc -clang++-$VERSION -c x.cc +echo '#include ' > foo.cc +clang++-$VERSION -c foo.cc echo ' #include @@ -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 -int main() {} ' > x.c -clang-$VERSION x.c +int main() {} ' > foo.c +clang-$VERSION foo.c echo '#include -int main() { }' > x.cpp -clang++-$VERSION -std=c++11 x.cpp +int main() { }' > foo.cpp +clang++-$VERSION -std=c++11 foo.cpp echo '#include int main() { @@ -163,15 +163,15 @@ int main (void) { std::vector 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 @@ -200,6 +200,7 @@ 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; } @@ -235,6 +236,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