From dfc2f8d5fb8c87c35d8f3db3c831bb60c174d86b Mon Sep 17 00:00:00 2001 From: wxiat Date: Wed, 14 Jun 2023 09:05:49 +0800 Subject: [PATCH 1/2] Add sw64 Signed-off-by: wxiat --- m4-1.4.18-sw.patch | 30 ++++++++++++++++++++++++++++++ m4.spec | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 m4-1.4.18-sw.patch diff --git a/m4-1.4.18-sw.patch b/m4-1.4.18-sw.patch new file mode 100644 index 0000000..8139b94 --- /dev/null +++ b/m4-1.4.18-sw.patch @@ -0,0 +1,30 @@ +diff -Naur m4-1.4.18.org/configure m4-1.4.18.sw/configure +--- m4-1.4.18.org/configure 2017-01-01 06:36:36.000000000 +0800 ++++ m4-1.4.18.sw/configure 2023-05-16 10:15:13.765091936 +0800 +@@ -6522,6 +6522,11 @@ + # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 + # and the GCC 4.1.2 manual). + case "$host_cpu" in ++ sw_64*) ++ if test -n "$GCC"; then ++ CPPFLAGS="$CPPFLAGS -mieee" ++ fi ++ ;; + alpha*) + # On Alpha systems, a compiler option provides the behaviour. + # See the ieee(3) manual page, also available at +diff -Naur m4-1.4.18.org/m4/fpieee.m4 m4-1.4.18.sw/m4/fpieee.m4 +--- m4-1.4.18.org/m4/fpieee.m4 2016-12-31 21:54:42.000000000 +0800 ++++ m4-1.4.18.sw/m4/fpieee.m4 2023-05-16 10:16:01.476775480 +0800 +@@ -30,6 +30,11 @@ + # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 + # and the GCC 4.1.2 manual). + case "$host_cpu" in ++ sw_64*) ++ if test -n "$GCC"; then ++ CPPFLAGS="$CPPFLAGS -mieee" ++ fi ++ ;; + alpha*) + # On Alpha systems, a compiler option provides the behaviour. + # See the ieee(3) manual page, also available at diff --git a/m4.spec b/m4.spec index 29c05ff..633298f 100644 --- a/m4.spec +++ b/m4.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 Summary: The GNU macro processor Name: m4 Version: 1.4.18 @@ -10,6 +10,7 @@ Source1: http://ftp.gnu.org/gnu/m4/m4-%{version}.tar.xz.sig URL: http://www.gnu.org/software/m4/ # Patch0: update to glibc libio.h removal, rhbz#1573342 Patch0: m4-1.4.18-glibc-change-work-around.patch +Patch1: m4-1.4.18-sw.patch Requires(post): /sbin/install-info Requires(preun): /sbin/install-info BuildRequires: autoconf automake @@ -49,6 +50,7 @@ Doc pages for %{name}. %setup -q %patch0 -p1 -b .glibc-change-work-around chmod 644 COPYING +%patch1 -p1 %build autoreconf -ivf @@ -84,6 +86,9 @@ if [ "$1" = 0 ]; then fi %changelog +* Tue May 16 2023 wxiat - 1.4.18-7.0.2 +- add sw patch + * Fri Jul 15 2022 Weisson - 1.4.18-7.0.1 - Add doc sub package -- Gitee From af3c2fc14c01556af1b87db5347fd3ed6f4c0d4f Mon Sep 17 00:00:00 2001 From: Weisson Date: Thu, 28 Mar 2024 14:56:16 +0800 Subject: [PATCH 2/2] stop using macro `SIGSTKSZ` on sw_64. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gnulib: c-stack: stop using SIGSTKSZ - from upstream #f9e2b20a12a230efa30f1d479563ae07d276a94b - reference #8ba9126d00bfe1ab77a5c820c58c68933d4df85c It’s been proposed to stop making SIGSTKSZ an integer constant: https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html Also, using SIGSTKSZ in #if did not conform to current POSIX. Also, avoiding SIGSTKSZ makes the code simpler and easier to grok. * lib/c-stack.c (SIGSTKSZ): Remove. (alternate_signal_stack): Now a 64 KiB array, for simplicity. All uses changed. Signed-off-by: Weisson --- ...id-compilation-error-with-glibc-2.34.patch | 54 +++++++ gnulib-c-stack-stop-using-SIGSTKSZ.patch | 141 ++++++++++++++++++ m4.spec | 11 +- 3 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 gnulib-Avoid-compilation-error-with-glibc-2.34.patch create mode 100644 gnulib-c-stack-stop-using-SIGSTKSZ.patch diff --git a/gnulib-Avoid-compilation-error-with-glibc-2.34.patch b/gnulib-Avoid-compilation-error-with-glibc-2.34.patch new file mode 100644 index 0000000..2a33147 --- /dev/null +++ b/gnulib-Avoid-compilation-error-with-glibc-2.34.patch @@ -0,0 +1,54 @@ +From d4574d24f54b859c716c1e258f26aa9a94d632ca Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 28 Mar 2024 14:07:48 +0800 +Subject: [PATCH] gnulib: Avoid compilation error with glibc >= 2.34. from + upstream #8e99f24c0931a38880c6ee9b8287c7da80b0036b + +Signed-off-by: Weisson +--- + m4/c-stack.m4 | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/m4/c-stack.m4 b/m4/c-stack.m4 +index aa9895e..f6265ac 100644 +--- a/m4/c-stack.m4 ++++ b/m4/c-stack.m4 +@@ -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 +@@ -207,6 +218,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 +-- +2.31.1 + diff --git a/gnulib-c-stack-stop-using-SIGSTKSZ.patch b/gnulib-c-stack-stop-using-SIGSTKSZ.patch new file mode 100644 index 0000000..eaf9e6e --- /dev/null +++ b/gnulib-c-stack-stop-using-SIGSTKSZ.patch @@ -0,0 +1,141 @@ +From e654dd3b2ea046d36a904b4a7a0376c9de9cde80 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Thu, 28 Mar 2024 14:24:38 +0800 +Subject: [PATCH] gnulib: c-stack: stop using SIGSTKSZ from upstream + #f9e2b20a12a230efa30f1d479563ae07d276a94b reference + #8ba9126d00bfe1ab77a5c820c58c68933d4df85c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It’s been proposed to stop making SIGSTKSZ an integer constant: +https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html +Also, using SIGSTKSZ in #if did not conform to current POSIX. +Also, avoiding SIGSTKSZ makes the code simpler and easier to grok. +* lib/c-stack.c (SIGSTKSZ): Remove. +(alternate_signal_stack): Now a 64 KiB array, for simplicity. +All uses changed. + +Signed-off-by: Weisson +--- + lib/c-stack.c | 52 ++++++++++++++++++++++----------------------------- + lib/c-stack.h | 2 +- + 2 files changed, 23 insertions(+), 31 deletions(-) + +diff --git a/lib/c-stack.c b/lib/c-stack.c +index 5353c08..eb5186e 100644 +--- a/lib/c-stack.c ++++ b/lib/c-stack.c +@@ -50,15 +50,6 @@ + #if ! HAVE_STACK_T && ! defined stack_t + typedef struct sigaltstack stack_t; + #endif +-#ifndef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 +-/* libsigsegv 2.6 through 2.8 have a bug where some architectures use +- more than the Linux default of an 8k alternate stack when deciding +- if a fault was caused by stack overflow. */ +-# undef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#endif + + #include + #include +@@ -71,7 +62,11 @@ typedef struct sigaltstack stack_t; + + #include + +-#if HAVE_LIBSIGSEGV ++/* Use libsigsegv only if needed; kernels like Solaris can detect ++ stack overflow without the overhead of an external library. */ ++#define USE_LIBSIGSEGV (HAVE_XSI_STACK_OVERFLOW_HEURISTIC && HAVE_LIBSIGSEGV) ++ ++#if USE_LIBSIGSEGV + # include + #endif + +@@ -89,6 +84,16 @@ typedef struct sigaltstack stack_t; + # endif + #endif + ++/* Storage for the alternate signal stack. ++ 64 KiB is not too large for Gnulib-using apps, and is large enough ++ for all known platforms. Smaller sizes may run into trouble. ++ For example, libsigsegv 2.6 through 2.8 have a bug where some ++ architectures use more than the Linux default of an 8 KiB alternate ++ stack when deciding if a fault was caused by stack overflow. */ ++static max_align_t alternate_signal_stack[(64 * 1024 ++ + sizeof (max_align_t) - 1) ++ / sizeof (max_align_t)]; ++ + /* The user-specified action to take when a SEGV-related program error + or stack overflow occurs. */ + static void (* volatile segv_action) (int); +@@ -128,19 +133,6 @@ die (int signo) + #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \ + && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV + +-/* Storage for the alternate signal stack. */ +-static union +-{ +- char buffer[SIGSTKSZ]; +- +- /* These other members are for proper alignment. There's no +- standard way to guarantee stack alignment, but this seems enough +- in practice. */ +- long double ld; +- long l; +- void *p; +-} alternate_signal_stack; +- + static void + null_action (int signo __attribute__ ((unused))) + { +@@ -205,8 +197,8 @@ c_stack_action (void (*action) (int)) + + /* Always install the overflow handler. */ + if (stackoverflow_install_handler (overflow_handler, +- alternate_signal_stack.buffer, +- sizeof alternate_signal_stack.buffer)) ++ alternate_signal_stack, ++ sizeof alternate_signal_stack)) + { + errno = ENOTSUP; + return -1; +@@ -279,14 +271,14 @@ c_stack_action (void (*action) (int)) + stack_t st; + struct sigaction act; + st.ss_flags = 0; ++ st.ss_sp = alternate_signal_stack; ++ st.ss_size = sizeof alternate_signal_stack; + # if SIGALTSTACK_SS_REVERSED + /* Irix mistakenly treats ss_sp as the upper bound, rather than + lower bound, of the alternate stack. */ +- st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *); +- st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *); +-# else +- st.ss_sp = alternate_signal_stack.buffer; +- st.ss_size = sizeof alternate_signal_stack.buffer; ++ st.ss_size -= sizeof (void *); ++ char *ss_sp = st.ss_sp; ++ st.ss_sp = ss_sp + st.ss_size; + # endif + r = sigaltstack (&st, NULL); + if (r != 0) +diff --git a/lib/c-stack.h b/lib/c-stack.h +index efd3b8f..1473d29 100644 +--- a/lib/c-stack.h ++++ b/lib/c-stack.h +@@ -34,7 +34,7 @@ + A null ACTION acts like an action that does nothing. + + ACTION must be async-signal-safe. ACTION together with its callees +- must not require more than SIGSTKSZ bytes of stack space. Also, ++ must not require more than 64 KiB bytes of stack space. Also, + ACTION should not call longjmp, because this implementation does + not guarantee that it is safe to return to the original stack. + +-- +2.31.1 + diff --git a/m4.spec b/m4.spec index 633298f..a0fb23f 100644 --- a/m4.spec +++ b/m4.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.2 +%define anolis_release .0.3 Summary: The GNU macro processor Name: m4 Version: 1.4.18 @@ -11,6 +11,8 @@ URL: http://www.gnu.org/software/m4/ # Patch0: update to glibc libio.h removal, rhbz#1573342 Patch0: m4-1.4.18-glibc-change-work-around.patch Patch1: m4-1.4.18-sw.patch +Patch2: gnulib-Avoid-compilation-error-with-glibc-2.34.patch +Patch3: gnulib-c-stack-stop-using-SIGSTKSZ.patch Requires(post): /sbin/install-info Requires(preun): /sbin/install-info BuildRequires: autoconf automake @@ -51,6 +53,10 @@ Doc pages for %{name}. %patch0 -p1 -b .glibc-change-work-around chmod 644 COPYING %patch1 -p1 +%ifarch sw_64 +%patch2 -p1 +%patch3 -p1 +%endif %build autoreconf -ivf @@ -86,6 +92,9 @@ if [ "$1" = 0 ]; then fi %changelog +* Thu Mar 28 2024 Weisson - 1.4.18-7.0.3 +- stop using macro `SIGSTKSZ` on sw_64. + * Tue May 16 2023 wxiat - 1.4.18-7.0.2 - add sw patch -- Gitee