From 8e99f24c0931a38880c6ee9b8287c7da80b0036b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 17 May 2021 02:13:12 +0200 Subject: [PATCH] sigsegv, c-stack: Avoid compilation error with glibc >= 2.34. * lib/sigsegv.in.h (SIGSTKSZ): On glibc systems, redefine to a suitable constant. * m4/sigaltstack.m4 (SV_SIGALTSTACK): Likewise. * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Likewise. --- ChangeLog | 8 ++++++++ lib/sigsegv.in.h | 13 +++++++++++-- m4/c-stack.m4 | 34 +++++++++++++++++++++++++++++++++- m4/sigaltstack.m4 | 22 +++++++++++++++++++++- 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88f7944268..e3ab1ff061 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-05-16 Bruno Haible + + sigsegv, c-stack: Avoid compilation error with glibc >= 2.34. + * lib/sigsegv.in.h (SIGSTKSZ): On glibc systems, redefine to a suitable + constant. + * m4/sigaltstack.m4 (SV_SIGALTSTACK): Likewise. + * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Likewise. + 2021-05-16 Bruno Haible sigsegv: Add tests. diff --git a/lib/sigsegv.in.h b/lib/sigsegv.in.h index 1c87acc111..e442f4dfa5 100644 --- a/lib/sigsegv.in.h +++ b/lib/sigsegv.in.h @@ -37,16 +37,25 @@ #endif /* Correct the value of SIGSTKSZ on some systems. + glibc >= 2.34: When _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But most programs need a simple constant. AIX 64-bit: original value 4096 is too small. HP-UX: original value 8192 is too small. Solaris 11/x86_64: original value 8192 is too small. */ +#include +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 65536 +# endif +#endif #if defined _AIX && defined _ARCH_PPC64 -# include # undef SIGSTKSZ # define SIGSTKSZ 8192 #endif #if defined __hpux || (defined __sun && (defined __x86_64__ || defined __amd64__)) -# include # undef SIGSTKSZ # define SIGSTKSZ 16384 #endif diff --git a/m4/c-stack.m4 b/m4/c-stack.m4 index 06b2594d43..3131dd5475 100644 --- a/m4/c-stack.m4 +++ b/m4/c-stack.m4 @@ -7,7 +7,7 @@ # Written by Paul Eggert. -# serial 21 +# serial 22 AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC], [ @@ -44,6 +44,17 @@ AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC], # include # include #endif + /* In glibc >= 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is + no longer a compile-time constant. But we need a simple + constant here. */ + #if __GLIBC__ >= 2 + # undef SIGSTKSZ + # if defined __ia64__ + # define SIGSTKSZ 262144 + # else + # define SIGSTKSZ 16384 + # endif + #endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif @@ -149,6 +160,16 @@ AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC], #if HAVE_SYS_SIGNAL_H # include #endif +/* In glibc >= 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But we need a simple constant here. */ +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 16384 +# endif +#endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif @@ -233,6 +254,17 @@ int main () # include # include #endif + /* In glibc >= 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is + no longer a compile-time constant. But we need a simple + constant here. */ + #if __GLIBC__ >= 2 + # undef SIGSTKSZ + # if defined __ia64__ + # define SIGSTKSZ 262144 + # else + # define SIGSTKSZ 16384 + # endif + #endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif diff --git a/m4/sigaltstack.m4 b/m4/sigaltstack.m4 index 212e9d36a7..837191e5f1 100644 --- a/m4/sigaltstack.m4 +++ b/m4/sigaltstack.m4 @@ -1,4 +1,4 @@ -# sigaltstack.m4 serial 12 +# sigaltstack.m4 serial 13 dnl Copyright (C) 2002-2021 Bruno Haible dnl Copyright (C) 2008 Eric Blake dnl This file is free software, distributed under the terms of the GNU @@ -53,6 +53,16 @@ AC_DEFUN([SV_SIGALTSTACK], # include # include #endif +/* In glibc >= 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But we need a simple constant here. */ +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 16384 +# endif +#endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif @@ -138,6 +148,16 @@ int main () #if HAVE_SYS_SIGNAL_H # include #endif +/* In glibc >= 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer a + compile-time constant. But we need a simple constant here. */ +#if __GLIBC__ >= 2 +# undef SIGSTKSZ +# if defined __ia64__ +# define SIGSTKSZ 262144 +# else +# define SIGSTKSZ 16384 +# endif +#endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 #endif -- 2.39.5