Subject: bug#29666: patch-FYI: fix link failure and suppress a warning

From: Jim Meyering <[email-masked]>
Date: Sun, 17 Dec 2017 08:33:28 -0800

Here are two patches.
The first suppresses a warning I saw when building with
gcc-8.0.0 20171215 on fedora 27. The second fixes a link
failure reported by Jeremy Feusi.

Subject: [PATCH 1/2] build: suppress sig-handler.h's -Wcast-function-type warning

* configure.ac (WERROR_CFLAGS): Add -Wno-cast-function-type
to suppress warning about sig-handler.h's sa_handler_t cast:
sig-handler.h: In function 'get_handler':
sig-handler.h:47:12: error: cast between incompatible function\
  types from 'void (* const)(int,  siginfo_t *, void *)'\
  {aka 'void (* const)(int,  struct <anonymous> *, void *)'}\
  to 'void (*)(int)' [-Werror=cast-function-type]
     return (sa_handler_t) a->sa_sigaction;
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 032c91b..59153dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,6 +149,7 @@ if test "$gl_gcc_warnings" = yes; then
   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+  gl_WARN_ADD([-Wno-cast-function-type]) # sig-handler.h's sa_handler_t cast

   # In spite of excluding -Wlogical-op above, it is enabled, as of
   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
--

Subject: [PATCH 2/2] build: link with -lsigsegv, when c-stack module requires it

* src/Makefile.am (grep_LDADD): Add $(LIBCSTACK).
Otherwise, on at least Debian and Arch-based systems, linking would
fail with diagnostics like these:
  c-stack.c:207: undefined reference to `stackoverflow_install_handler'
  c-stack.c:216: undefined reference to `sigsegv_install_handler'
Reported by Jeremy Feusi.
---
 src/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 71c64f9..7a0cdef 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,7 @@ LDADD = \
   ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a $(LIBICONV) \
   $(LIBTHREAD)

-grep_LDADD = $(LDADD) $(PCRE_LIBS)
+grep_LDADD = $(LDADD) $(PCRE_LIBS) $(LIBCSTACK)
 localedir = $(datadir)/locale
 AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib

--