Bug#777887: google-perftools: diff for NMU version 2.2.1-0.3

2016-02-20 Thread Aliaksey Kandratsenka
Hi all.

I'm maintainer of upstream gperftools. Please keep in mind that latest
release is gperftools 2.4 and we've moved to
github.com/gpeftools/gperftools

On Sat, Feb 20, 2016 at 8:49 AM, Julien Cristau  wrote:
> Control: tags 777887 + patch
> Control: tags 777887 + pending
>
> Dear maintainer,
>
> I've prepared an NMU for google-perftools (versioned as 2.2.1-0.3) and
> am about to upload it.
>
> Cheers,
> Julien



Bug#777887: google-perftools: diff for NMU version 2.2.1-0.3

2016-02-20 Thread Julien Cristau
Control: tags 777887 + patch
Control: tags 777887 + pending

Dear maintainer,

I've prepared an NMU for google-perftools (versioned as 2.2.1-0.3) and
am about to upload it.

Cheers,
Julien
diff -u google-perftools-2.2.1/debian/changelog google-perftools-2.2.1/debian/changelog
--- google-perftools-2.2.1/debian/changelog
+++ google-perftools-2.2.1/debian/changelog
@@ -1,3 +1,11 @@
+google-perftools (2.2.1-0.3) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Apply upstream patches to fix test failures with gcc 5 (closes: #777887)
+  * Pass --add-missing to automake to fix build failure.
+
+ -- Julien Cristau   Sat, 20 Feb 2016 16:42:10 +
+
 google-perftools (2.2.1-0.2) unstable; urgency=low
 
   * Non-maintainer upload.
diff -u google-perftools-2.2.1/debian/rules google-perftools-2.2.1/debian/rules
--- google-perftools-2.2.1/debian/rules
+++ google-perftools-2.2.1/debian/rules
@@ -17,6 +17,7 @@
 DEB_AUTO_UPDATE_AUTOMAKE = 1.11
 DEB_AUTO_UPDATE_ACLOCAL = $(DEB_AUTO_UPDATE_AUTOMAKE)
 DEB_AUTO_UPDATE_LIBTOOL = pre
+DEB_AUTOMAKE_ARGS = --add-missing
 DEB_INSTALL_CHANGELOGS_ALL := ChangeLog
 
 ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
only in patch2:
unchanged:
--- google-perftools-2.2.1.orig/debian/patches/unbreak-heap-profiler-unittest-on-gcc-5.patch
+++ google-perftools-2.2.1/debian/patches/unbreak-heap-profiler-unittest-on-gcc-5.patch
@@ -0,0 +1,39 @@
+From eb725ff26371dfb5ae2523802c6abe75833cacef Mon Sep 17 00:00:00 2001
+From: Aliaksey Kandratsenka 
+Date: Sat, 1 Aug 2015 20:54:39 -0700
+Subject: [PATCH] unbreak heap-profiler-unittest on gcc 5
+
+gcc 5 has got nice new optimization (-fipa-icf) which merges identical
+functions into one. And that causes heap-profiler_unittest to fail
+since it expects to see both Allocate and Allocate2 in heap
+profiles. And smart GCC detects that they are same function and makes
+one function out of two and thus breaks this test.
+
+New code simply adds (disabled) logging calls to make those functions
+non-identical.
+---
+ src/tests/heap-profiler_unittest.cc | 4 
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/tests/heap-profiler_unittest.cc b/src/tests/heap-profiler_unittest.cc
+index c71e56b..3317813 100644
+--- a/src/tests/heap-profiler_unittest.cc
 b/src/tests/heap-profiler_unittest.cc
+@@ -58,6 +58,9 @@ static const int kMaxCount = 10;
+ int* g_array[kMaxCount];  // an array of int-vectors
+ 
+ static ATTRIBUTE_NOINLINE void Allocate(int start, int end, int size) {
++  // NOTE: we're using this to prevent gcc 5 from merging otherwise
++  // identical Allocate & Allocate2 functions.
++  VLOG(10, "Allocate");
+   for (int i = start; i < end; ++i) {
+ if (i < kMaxCount)
+   g_array[i] = new int[size];
+@@ -65,6 +68,7 @@ static ATTRIBUTE_NOINLINE void Allocate(int start, int end, int size) {
+ }
+ 
+ static ATTRIBUTE_NOINLINE void Allocate2(int start, int end, int size) {
++  VLOG(10, "Allocate2");
+   for (int i = start; i < end; ++i) {
+ if (i < kMaxCount)
+   g_array[i] = new int[size];
only in patch2:
unchanged:
--- google-perftools-2.2.1.orig/debian/patches/unbreak-heap_checker_unittest-on-gcc-5.patch
+++ google-perftools-2.2.1/debian/patches/unbreak-heap_checker_unittest-on-gcc-5.patch
@@ -0,0 +1,41 @@
+From 53833298f3822b2b8b78c9dc85160d65d78a6857 Mon Sep 17 00:00:00 2001
+From: Aliaksey Kandratsenka 
+Date: Sat, 1 Aug 2015 19:46:34 -0700
+Subject: [PATCH] unbreak heap_checker_unittest on gcc 5
+
+GCC 5 ended up too smart and optimized out assignment of allocated
+block to global variable. Which caused test to fail since it triggered
+unexpected "leak".
+---
+ src/tests/heap-checker_unittest.cc | 12 
+ 1 file changed, 12 insertions(+)
+
+diff --git a/src/tests/heap-checker_unittest.cc b/src/tests/heap-checker_unittest.cc
+index 13cbb86..8c8f865 100644
+--- a/src/tests/heap-checker_unittest.cc
 b/src/tests/heap-checker_unittest.cc
+@@ -1241,12 +1241,24 @@ REGISTER_OBJ_MAKER(nesting_i1, Nesting::Inner* p = &((new Nesting())->i1);)
+ REGISTER_OBJ_MAKER(nesting_i2, Nesting::Inner* p = &((new Nesting())->i2);)
+ REGISTER_OBJ_MAKER(nesting_i3, Nesting::Inner* p = &((new Nesting())->i3);)
+ 
++void (* volatile init_forcer)(...);
++
+ // allocate many objects reachable from global data
+ static void TestHeapLeakCheckerLiveness() {
+   live_leak_mutable.ptr = new(initialized) char[77];
+   live_leak_templ_mutable.ptr = new(initialized) Array();
+   live_leak_templ_mutable.val = Array();
+ 
++  // smart compiler may see that live_leak_mutable is not used
++  // anywhere so .ptr assignment is not used.
++  //
++  // We force compiler to assume that it is used by having function
++  // variable (set to 0 which hopefully won't be known to compiler)
++  // which gets address of those objects. So compiler has to assume
++  // that .ptr is used.
++  if (init_forcer) {
++init_forcer(_leak_mutable, _leak_templ_mutable);
++  }
+   TestObjMakers();