From 78982e2b845ed0a4e1c3d6dac738e0ed69b0cdbc Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 18 Sep 2017 19:53:51 +0000 Subject: [PATCH] * Backport of an arm patch for rust. https://bugs.llvm.org/show_bug.cgi?id=32379 (Closes: #876072) * Fix sanitizer build failure with glibc-2.26. * build using gold on arm64 and s390x. For backports, arm64 might still need the BFD linker, and building with only one or two processes in parallel. * On amd64, s390x, arm64 and ppc64el, build with -g1 instead of -g. * Set CMAKE_CXX_FLAGS_RELWITHDEBINFO and pass opt_flags. --- debian/changelog | 12 +++- debian/control | 4 ++ debian/patches/armhf-bitfield.diff | 39 +++++++++++ debian/patches/pr81066.diff | 102 +++++++++++++++++++++++++++++ debian/patches/series | 2 + debian/rules | 6 +- 6 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 debian/patches/armhf-bitfield.diff create mode 100644 debian/patches/pr81066.diff diff --git a/debian/changelog b/debian/changelog index 3f377274..a99826df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,17 @@ -llvm-toolchain-4.0 (1:5.0-1~exp2) UNRELEASED; urgency=medium +llvm-toolchain-4.0 (1:4.0.1-5) unstable; urgency=medium + + * Backport of an arm patch for rust. + https://bugs.llvm.org/show_bug.cgi?id=32379 + (Closes: #876072) [ Matthias Klose ] * Link with --no-keep-files-mapped --no-map-whole-files when using gold. + * Fix sanitizer build failure with glibc-2.26. + * build using gold on arm64 and s390x. For backports, arm64 might still + need the BFD linker, and building with only one or two processes in + parallel. + * On amd64, s390x, arm64 and ppc64el, build with -g1 instead of -g. + * Set CMAKE_CXX_FLAGS_RELWITHDEBINFO and pass opt_flags. -- Sylvestre Ledru Fri, 08 Sep 2017 11:59:03 +0200 diff --git a/debian/control b/debian/control index 36da61eb..c451ebe4 100644 --- a/debian/control +++ b/debian/control @@ -229,6 +229,8 @@ Section: libs Depends: ${shlibs:Depends}, ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} Multi-Arch: same +Breaks: libllvm3.9v4 +Replaces: libllvm3.9v4 Description: Modular compiler and toolchain technologies, runtime library LLVM is a collection of libraries and tools that make it easy to build compilers, optimizers, just-in-time code generators, and many other @@ -243,6 +245,8 @@ Priority: extra Depends: ${shlibs:Depends}, ${misc:Depends}, libllvm4.0 (= ${binary:Version}) Pre-Depends: ${misc:Pre-Depends} Multi-Arch: same +Breaks: libllvm3.9v4-dbg +Replaces: libllvm3.9v4-dbg Description: Modular compiler and toolchain technologies, debugging libraries LLVM is a collection of libraries and tools that make it easy to build compilers, optimizers, just-in-time code generators, and many other diff --git a/debian/patches/armhf-bitfield.diff b/debian/patches/armhf-bitfield.diff new file mode 100644 index 00000000..0b3a661b --- /dev/null +++ b/debian/patches/armhf-bitfield.diff @@ -0,0 +1,39 @@ +Index: llvm-toolchain-3.9-3.9.1/lib/Target/ARM/ARMISelLowering.cpp +=================================================================== +--- llvm-toolchain-3.9-3.9.1.orig/lib/Target/ARM/ARMISelLowering.cpp ++++ llvm-toolchain-3.9-3.9.1/lib/Target/ARM/ARMISelLowering.cpp +@@ -10805,8 +10805,8 @@ static void computeKnownBits(SelectionDA + if (Op.getOpcode() == ARMISD::CMOV) { + APInt KZ2(KnownZero.getBitWidth(), 0); + APInt KO2(KnownOne.getBitWidth(), 0); +- computeKnownBits(DAG, Op.getOperand(1), KnownZero, KnownOne); +- computeKnownBits(DAG, Op.getOperand(2), KZ2, KO2); ++ computeKnownBits(DAG, Op.getOperand(0), KnownZero, KnownOne); ++ computeKnownBits(DAG, Op.getOperand(1), KZ2, KO2); + + KnownZero &= KZ2; + KnownOne &= KO2; +Index: llvm-toolchain-3.9-3.9.1/test/CodeGen/ARM/no-cmov2bfi.ll +=================================================================== +--- /dev/null ++++ llvm-toolchain-3.9-3.9.1/test/CodeGen/ARM/no-cmov2bfi.ll +@@ -0,0 +1,19 @@ ++; RUN: llc < %s -mtriple=thumbv7 | FileCheck --check-prefix=CHECK-NOBFI %s ++ ++declare zeroext i1 @dummy() ++ ++define i8 @test(i8 %a1, i1 %c) { ++; CHECK-NOBFI-NOT: bfi ++; CHECK-NOBFI: bl dummy ++; CHECK-NOBFI: cmp r0, #0 ++; CHECK-NOBFI: it ne ++; CHECK-NOBFI: orrne [[REG:r[0-9]+]], [[REG]], #8 ++; CHECK-NOBFI: mov r0, [[REG]] ++ ++ %1 = and i8 %a1, -9 ++ %2 = select i1 %c, i8 %1, i8 %a1 ++ %3 = tail call zeroext i1 @dummy() ++ %4 = or i8 %2, 8 ++ %ret = select i1 %3, i8 %4, i8 %2 ++ ret i8 %ret ++} diff --git a/debian/patches/pr81066.diff b/debian/patches/pr81066.diff new file mode 100644 index 00000000..e3e39cf3 --- /dev/null +++ b/debian/patches/pr81066.diff @@ -0,0 +1,102 @@ +# DP; Fix PR sanitizer/81066, taken from the gcc-7-branch. + +libsanitizer/ + +2017-07-17 Jakub Jelinek + + Backported from mainline + 2017-07-14 Jakub Jelinek + + PR sanitizer/81066 + * sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969. + * sanitizer_common/sanitizer_linux.cc: Likewise. + * sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise. + * tsan/tsan_platform_linux.cc: Likewise. + +Index: b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +=================================================================== +--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc ++++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +@@ -607,8 +607,7 @@ uptr internal_prctl(int option, uptr arg + } + #endif + +-uptr internal_sigaltstack(const struct sigaltstack *ss, +- struct sigaltstack *oss) { ++uptr internal_sigaltstack(const void *ss, void *oss) { + return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); + } + +Index: b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h +=================================================================== +--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h ++++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h +@@ -21,7 +21,6 @@ + #include "sanitizer_platform_limits_posix.h" + + struct link_map; // Opaque type returned by dlopen(). +-struct sigaltstack; + + namespace __sanitizer { + // Dirent structure for getdents(). Note that this structure is different from +@@ -30,8 +29,7 @@ struct linux_dirent; + + // Syscall wrappers. + uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); +-uptr internal_sigaltstack(const struct sigaltstack* ss, +- struct sigaltstack* oss); ++uptr internal_sigaltstack(const void* ss, void* oss); + uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, + __sanitizer_sigset_t *oldset); + +Index: b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +=================================================================== +--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc ++++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +@@ -273,7 +273,7 @@ static int TracerThread(void* argument) + + // Alternate stack for signal handling. + InternalScopedBuffer handler_stack_memory(kHandlerStackSize); +- struct sigaltstack handler_stack; ++ stack_t handler_stack; + internal_memset(&handler_stack, 0, sizeof(handler_stack)); + handler_stack.ss_sp = handler_stack_memory.data(); + handler_stack.ss_size = kHandlerStackSize; +Index: b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +=================================================================== +--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc ++++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc +@@ -282,7 +282,7 @@ void InitializePlatform() { + int ExtractResolvFDs(void *state, int *fds, int nfd) { + #if SANITIZER_LINUX && !SANITIZER_ANDROID + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; +Index: b/compiler-rt/lib/asan/asan_linux.cc +=================================================================== +--- a/compiler-rt/lib/asan/asan_linux.cc ++++ b/compiler-rt/lib/asan/asan_linux.cc +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +Index: b/compiler-rt/lib/esan/esan_sideline_linux.cpp +=================================================================== +--- a/compiler-rt/lib/esan/esan_sideline_linux.cpp ++++ b/compiler-rt/lib/esan/esan_sideline_linux.cpp +@@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Ar + + // Set up a signal handler on an alternate stack for safety. + InternalScopedBuffer StackMap(SigAltStackSize); +- struct sigaltstack SigAltStack; ++ stack_t SigAltStack; + SigAltStack.ss_sp = StackMap.data(); + SigAltStack.ss_size = SigAltStackSize; + SigAltStack.ss_flags = 0; diff --git a/debian/patches/series b/debian/patches/series index 6fdb4a3f..afc43743 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -47,3 +47,5 @@ silent-amdgpu-test-failing.diff pthread-link.diff add_symbols_versioning.patch ftfbs-gcc.diff +pr81066.diff +armhf-bitfield.diff diff --git a/debian/rules b/debian/rules index a737dc98..2ed54831 100755 --- a/debian/rules +++ b/debian/rules @@ -62,6 +62,9 @@ export CC=gcc-$(GCC_VERSION) export CXX=g++-$(GCC_VERSION) opt_flags = -g -O2 +ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el s390x)) + opt_flags = -g1 -O2 +endif ifneq (,$(findstring $(DEB_HOST_ARCH),armel)) opt_flags += -marm # 3.8 fails to build, disable the compiler_rt builtins @@ -82,7 +85,7 @@ else control_vars = '-Vdep:devlibs=libstdc++6-$(GCC_VERSION)-dev' endif -BINUTILS_GOLD_ARCHS := amd64 armhf i386 powerpcspe ppc64 ppc64el sparc sparc64 x32 +BINUTILS_GOLD_ARCHS := amd64 arm64 armhf i386 powerpcspe ppc64 ppc64el sparc sparc64 x32 s390x ifeq ($(shell dpkg --compare-versions $(shell dpkg-query -W -f '$${Version}' binutils) ge 2.23.1-1~exp3 ; echo $$?),0) ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS))) # -fused-ld=gold enables the gold linker (but is not supported by all archs / distro) @@ -275,6 +278,7 @@ override_dh_auto_configure: preconfigure -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$(LLVM_VERSION) \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(opt_flags)" \ -DCMAKE_CXX_FLAGS='$(CXXFLAGS_EXTRA)' \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_INSTALL_UTILS=ON \