Package: gtk-gnutella
Severity: serious
Tags: patch ftbfs
Justification: fails to build from source (but built successfully in the past)
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu kinetic ubuntu-patch

Hi,

This is technically not a problem in Debian yet, since sid is on glibc
2.33. But, once glibc >= 2.34 is in place, this package will FTBFS. The
cause is that gtk-gnutella uses preprocessor directives to check
PTHREAD_STACK_MIN at compile time, but in glibc >= 2.34,
PTHREAD_STACK_MIN may be dynamic and cannot be checked at compile time.

In Ubuntu, we pulled an upstream patch to fix compilation with newer
glibc:

  * debian/patches/0001-Fix-compilation-with-newest-glibc.patch: Fix FTBFS
    against glibc >= 2.34 by checking dynamically-defined PTHREAD_STACK_MIN 
    at run time instead of compile time (LP: #1981474).

This patch should be safe for glibc < 2.34 as well.

Thanks,
Nick
diff -Nru 
gtk-gnutella-1.1.15/debian/patches/0001-Fix-compilation-with-newest-glibc.patch 
gtk-gnutella-1.1.15/debian/patches/0001-Fix-compilation-with-newest-glibc.patch
--- 
gtk-gnutella-1.1.15/debian/patches/0001-Fix-compilation-with-newest-glibc.patch 
    1969-12-31 19:00:00.000000000 -0500
+++ 
gtk-gnutella-1.1.15/debian/patches/0001-Fix-compilation-with-newest-glibc.patch 
    2022-07-12 14:20:53.000000000 -0400
@@ -0,0 +1,63 @@
+Description: Fix compilation with newest glibc
+  The PTHREAD_STACK_MIN value is no longer a constant but rather
+  defined as sysconf(_SC_THREAD_STACK_MIN).
+Author: Raphael Manfredi <r...@entique.fr>
+Origin: upstream, 
https://github.com/gtk-gnutella/gtk-gnutella/commit/31d06cecac572852c6e5e8d85cea641883cbe4c6
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gtk-gnutella/+bug/1981474
+Last-Update: 2022-07-12
+---
+From: Raphael Manfredi <r...@entique.fr>
+Date: Mon, 9 Aug 2021 09:36:00 +0200
+Subject: [PATCH] Fix compilation with newest glibc.
+
+The PTHREAD_STACK_MIN value is no longer a constant but rather
+defined as sysconf(_SC_THREAD_STACK_MIN).
+
+Therefore, we must avoid using cpp computations on that value.
+---
+ src/lib/thread.c | 7 +------
+ src/lib/thread.h | 2 +-
+ 2 files changed, 2 insertions(+), 7 deletions(-)
+
+diff --git a/src/lib/thread.c b/src/lib/thread.c
+index 178c09794..e7a702029 100644
+--- a/src/lib/thread.c
++++ b/src/lib/thread.c
+@@ -9705,7 +9705,7 @@ thread_launch_trampoline(void *arg)
+  * In case PTHREAD_STACK_MIN is not defined by <pthread.h>.
+  */
+ #ifndef PTHREAD_STACK_MIN
+-#define PTHREAD_STACK_MIN 0
++#define PTHREAD_STACK_MIN 1024U
+ #endif
+ 
+ /**
+@@ -9737,12 +9737,7 @@ thread_launch(struct thread_element *te,
+       pthread_attr_init(&attr);
+ 
+       if (stack != 0) {
+-              /* Avoid compiler warning when PTHREAD_STACK_MIN == 0 */
+-#if PTHREAD_STACK_MIN != 0
+               stacksize = MAX(PTHREAD_STACK_MIN, stack);
+-#else
+-              stacksize = stack;
+-#endif
+               stacksize = MAX(stacksize, THREAD_STACK_MIN);
+       } else {
+               stacksize = MAX(THREAD_STACK_DFLT, PTHREAD_STACK_MIN);
+diff --git a/src/lib/thread.h b/src/lib/thread.h
+index 73e15fa36..740f3a6f9 100644
+--- a/src/lib/thread.h
++++ b/src/lib/thread.h
+@@ -63,7 +63,7 @@ typedef size_t thread_qid_t;         /* Quasi Thread ID */
+ typedef unsigned int thread_key_t;    /* Local thread storage key */
+ 
+ #define THREAD_MAX                    64              /**< Max amount of 
threads we can track */
+-#define THREAD_STACK_DFLT     (65536 * PTRSIZE)       /**< Default stack 
requested */
++#define THREAD_STACK_DFLT     (65536U * PTRSIZE)      /**< Default stack 
requested */
+ #define THREAD_LOCAL_MAX      1024    /**< Max amount of thread-local keys */
+ 
+ #define THREAD_SUSPEND_TIMEOUT        90      /**< secs: thread max 
suspension time */
+-- 
+2.34.1
+
diff -Nru gtk-gnutella-1.1.15/debian/patches/series 
gtk-gnutella-1.1.15/debian/patches/series
--- gtk-gnutella-1.1.15/debian/patches/series   2020-02-26 04:01:31.000000000 
-0500
+++ gtk-gnutella-1.1.15/debian/patches/series   2022-07-12 14:17:33.000000000 
-0400
@@ -1 +1,2 @@
 # Auto-applied patches
+0001-Fix-compilation-with-newest-glibc.patch

Reply via email to