Fix undefined pthread_setname_np

https://fedoraproject.org/wiki/Toolchain/PortingToModernC
This commit is contained in:
Timm Bäder 2023-01-17 10:36:43 +01:00
parent 0f9f8891ae
commit 943dd49c9b
2 changed files with 29 additions and 1 deletions

View File

@ -1,7 +1,7 @@
Summary: Garbage collector for C and C++
Name: gc
Version: 8.2.2
Release: 1%{?dist}
Release: 2%{?dist}
License: BSD
URL: https://www.hboehm.info/gc/
@ -10,6 +10,8 @@ Source0: https://github.com/ivmai/bdwgc/releases/download/v%{version}/gc-%{versi
## upstreamable patches
## downstream patches
# Already upstream: https://github.com/ivmai/bdwgc/commit/4489757f1cc1fe4aa98d4c1ebbe0789b2b308e11
Patch0: pthread_setname_np.patch
BuildRequires: automake libtool
BuildRequires: gcc-c++
@ -105,6 +107,10 @@ make check %{?arch_ignore}
%changelog
* Tue Jan 17 2023 Timm Bäder <tbaeder@redhat.com> - 8.2.2-2
- Fix undefined pthread_setname_np
- https://fedoraproject.org/wiki/Toolchain/PortingToModernC
* Tue Sep 20 2022 Rex Dieter <rdieter@fedoraproject.org> 8.2.2-1
- 8.2.2 (#2124760)

22
pthread_setname_np.patch Normal file
View File

@ -0,0 +1,22 @@
diff -ruN gc-8.2.2.orig/configure.ac gc-8.2.2/configure.ac
--- gc-8.2.2.orig/configure.ac 2022-08-26 20:44:49.000000000 +0200
+++ gc-8.2.2/configure.ac 2023-01-17 10:24:04.342866823 +0100
@@ -833,13 +833,15 @@
AS_IF([test "$THREADS" = posix],
[AC_MSG_CHECKING(for pthread_setname_np)
old_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
- AC_TRY_COMPILE([#include <pthread.h>],
+ CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror -pthread"
+ AC_TRY_COMPILE([#define _GNU_SOURCE
+ #include <pthread.h>],
[pthread_setname_np("thread-name")],
[AC_MSG_RESULT([yes (w/o tid)])
AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1],
[Define to use 'pthread_setname_np(const char*)' function.])],
- [AC_TRY_COMPILE([#include <pthread.h>],
+ [AC_TRY_COMPILE([#define _GNU_SOURCE
+ #include <pthread.h>],
[pthread_setname_np(pthread_self(), "thread-name-%u", 0)],
[AC_MSG_RESULT([yes (with tid and arg)])
AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1],