Files
RedBear-OS/local/patches/termcap/01-honour-configure-cflags.patch
T
vasilito 893f98a2cf build: cancel -fhardened; fix termcap for GCC 16; regenerate pam-redbear lock
Three GCC 16 gaps found by the redbear-full build.

-fhardened (seatd and other meson recipes, 24 errors)
  -fhardened is a host-glibc hardening bundle x86_64-unknown-redox cannot
  implement, but GCC accepts it on the command line, so meson's
  cc.has_argument('-fhardened') probe answers YES and meson adds it to
  every compile. GCC then refuses it for real:
    cc1: error: '-fhardened' not supported for this target [-Werror]
  Note the tag is [-Werror], not [-Werror=hardened] -- it is an
  unconditional warning, so -Wno-hardened does not silence it (tried, and
  it did not). The flag has to be cancelled instead; -fno-hardened does
  that cleanly and the cookbook's flags are appended after the project's
  own, so it wins. Nothing is weakened: the compiler is telling us the
  option is inert on this target.

termcap (two independent defects, both latent until now)
  1. Makefile.in hardcoded 'CFLAGS = -g' and has no @CFLAGS@ substitution
     at all, so nothing configure resolved ever reached the compiler --
     including the toolchain's default C dialect. termcap is pre-ANSI
     code, so being compiled as GCC 16's default C23 failed at once with
     'too many arguments to function malloc; expected 0, have 1'.
     Substituting @CFLAGS@ is what a normal autotools Makefile.in does.
  2. With CFLAGS flowing, the remaining errors were implicit declarations
     of strlen/memcpy/exit/write, which GCC 14+ makes errors regardless of
     -std. Cause: autoconf 2.70+ removed AC_HEADER_STDC, so STDC_HEADERS
     is never defined and termcap.c/tparam.c took their pre-ANSI branch,
     declaring 'char *malloc ();' instead of including <stdlib.h>.
     Autoconf's guidance on dropping AC_HEADER_STDC is to assume those
     headers exist, which holds for every target Red Bear builds.

pam-redbear
  Cargo.lock missed by the earlier sweep; regenerated for the 0.3.2 fork
  versions.

termcap and seatd now cook clean.
2026-08-03 15:32:29 +03:00

82 lines
2.9 KiB
Diff

Second half: autoconf 2.70+ removed AC_HEADER_STDC, so STDC_HEADERS is never
defined and termcap.c/tparam.c fell through to their pre-ANSI branch --
declaring `char *malloc ();` instead of including <stdlib.h>/<string.h>.
GCC 14+ makes implicit declarations an error, so even with -std=gnu17 the
build fails on strlen/memcpy/exit/strcpy/strcmp/write. Autoconf's own
guidance on dropping AC_HEADER_STDC is to assume those headers exist, which
holds for every target Red Bear builds, so include them unconditionally.
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,10 @@
DEFS = @DEFS@ -DTERMCAP_FILE=\"$(termcapfile)\"
-CFLAGS = -g
+# Red Bear: was hardcoded to `-g`, which discarded everything configure
+# computed. Substitute what configure resolved, as a normal autotools
+# Makefile.in does.
+CFLAGS = @CFLAGS@
prefix = @prefix@
exec_prefix = @exec_prefix@
--- a/termcap.c
+++ b/termcap.c
@@ -36,17 +36,20 @@
#else /* not emacs */
-#ifdef STDC_HEADERS
+/* Red Bear: autoconf 2.70+ removed AC_HEADER_STDC, so STDC_HEADERS is never
+ defined any more and this fell through to the pre-ANSI branch. Under GCC 14+
+ that is fatal -- implicit declarations are errors -- giving
+ error: implicit declaration of function 'strlen'
+ error: implicit declaration of function 'memcpy'
+ and the K&R `char *malloc ();` declarations conflict with the real
+ prototypes. Autoconf's own guidance on dropping AC_HEADER_STDC is to assume
+ these headers exist, which is true for every target Red Bear builds. */
#include <stdlib.h>
#include <string.h>
-#else
-char *getenv ();
-char *malloc ();
-char *realloc ();
-#endif
+#include <unistd.h>
/* Do this after the include, in case string.h prototypes bcopy. */
-#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
+#if !defined(bcopy) /* Red Bear: <string.h> is now unconditional */
#define bcopy(s, d, n) memcpy ((d), (s), (n))
#endif
--- a/tparam.c
+++ b/tparam.c
@@ -25,16 +25,20 @@
#include "lisp.h" /* for xmalloc */
#else
-#ifdef STDC_HEADERS
+/* Red Bear: autoconf 2.70+ removed AC_HEADER_STDC, so STDC_HEADERS is never
+ defined any more and this fell through to the pre-ANSI branch. Under GCC 14+
+ that is fatal -- implicit declarations are errors -- giving
+ error: implicit declaration of function 'strlen'
+ error: implicit declaration of function 'memcpy'
+ and the K&R `char *malloc ();` declarations conflict with the real
+ prototypes. Autoconf's own guidance on dropping AC_HEADER_STDC is to assume
+ these headers exist, which is true for every target Red Bear builds. */
#include <stdlib.h>
#include <string.h>
-#else
-char *malloc ();
-char *realloc ();
-#endif
+#include <unistd.h>
/* Do this after the include, in case string.h prototypes bcopy. */
-#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
+#if !defined(bcopy) /* Red Bear: <string.h> is now unconditional */
#define bcopy(s, d, n) memcpy ((d), (s), (n))
#endif