development, linux,

m4 1.4.17 fails to compile

agowa338 agowa338 Feb 04, 2020 · 4 mins read
Share this

While following the cross linux from scratch instructions over here I ran into this issue:

 freadahead.c: In function 'freadahead': freadahead.c:91:3:
error: #error "Please port gnulib freadahead.c to your platform! Look at the
definition of fflush, fread, ungetc on your system, then report this to
bug-gnulib." #error "Please port gnulib freadahead.c to your platform! Look at
the definition of fflush, fread, ungetc on your system, then report this to
bug-gnulib." ^~~~~ make[3]: *** [Makefile:1837: freadahead.o] Error 1 make[3]:
Leaving directory '/tmp/m4-1.4.17/lib' make[2]: *** [Makefile:1602: all] Error 2
make[2]: Leaving directory '/tmp/m4-1.4.17/lib' make[1]: *** [Makefile:1506:
all-recursive] Error 1 make[1]: Leaving directory '/tmp/m4-1.4.17' make: ***
[Makefile:1461: all] Error 2 

m4 does not compile with newer versions of gcc, therefore this patch is needed (thanks to stack overflow for linking to the 1.4.18 version, but as clfs uses 1.4.17 here is the port:

 diff -ur m4-1.4.17/lib/fflush.c
m4-1.4.17-patch/lib/fflush.c --- m4-1.4.17/lib/fflush.c 2013-09-22
08:15:20.000000000 +0200 +++ m4-1.4.17-patch/lib/fflush.c 2020-02-04
17:23:47.964372943 +0100 @@ -33,7 +33,7 @@ #undef fflush -#if defined
_IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5
*/ +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
Linux libc5 */ /* Clear the stream's ungetc buffer, preserving the value of
ftello (fp). */ static void @@ -71,7 +71,7 @@ #endif -#if ! (defined
_IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5
*/) +#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS,
Haiku, Linux libc5 */) # if (defined __sferror || defined __DragonFly__) &&
defined __SNPT /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ @@
-145,7 +145,7 @@ if (stream == NULL || ! freading (stream)) return fflush
(stream); -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc,
BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /*
GNU libc, BeOS, Haiku, Linux libc5 */ clear_ungetc_buffer_preserving_position
(stream); diff -ur m4-1.4.17/lib/fpurge.c m4-1.4.17-patch/lib/fpurge.c ---
m4-1.4.17/lib/fpurge.c 2013-09-22 08:15:20.000000000 +0200 +++
m4-1.4.17-patch/lib/fpurge.c 2020-02-04 17:23:47.964372943 +0100 @@ -61,7 +61,7
@@ /* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h
  >, because they need it for implementing getc() and putc() as fast macros. */
  -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS,
  Haiku, Linux libc5 */ +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /*
  GNU libc, BeOS, Haiku, Linux libc5 */ fp->_IO_read_end = fp->_IO_read_ptr;
  fp->_IO_write_ptr = fp->_IO_write_base; /* Avoid memory leak when there is an
  active ungetc buffer. */ diff -ur m4-1.4.17/lib/freadahead.c
  m4-1.4.17-patch/lib/freadahead.c --- m4-1.4.17/lib/freadahead.c 2013-09-22
  08:15:20.000000000 +0200 +++ m4-1.4.17-patch/lib/freadahead.c 2020-02-04
  17:23:47.976373311 +0100 @@ -25,7 +25,7 @@ size_t freadahead (FILE *fp) { -#if
  defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku,
  Linux libc5 */ +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc,
  BeOS, Haiku, Linux libc5 */ if (fp->_IO_write_ptr > fp->_IO_write_base) return
  0; return (fp->_IO_read_end - fp->_IO_read_ptr) diff -ur
  m4-1.4.17/lib/freading.c m4-1.4.17-patch/lib/freading.c ---
  m4-1.4.17/lib/freading.c 2013-09-22 08:15:20.000000000 +0200 +++
  m4-1.4.17-patch/lib/freading.c 2020-02-04 17:23:47.972373188 +0100 @@ -31,7
  +31,7 @@ /* Most systems provide FILE as a struct and the necessary bitmask in
  <stdio.h
    >, because they need it for implementing getc() and putc() as fast macros.
    */ -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS,
    Haiku, Linux libc5 */ +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /*
    GNU libc, BeOS, Haiku, Linux libc5 */ return ((fp->_flags & _IO_NO_WRITES)
    != 0 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 &&
    fp->_IO_read_base != NULL)); diff -ur m4-1.4.17/lib/fseeko.c
    m4-1.4.17-patch/lib/fseeko.c --- m4-1.4.17/lib/fseeko.c 2013-09-22
    08:15:55.000000000 +0200 +++ m4-1.4.17-patch/lib/fseeko.c 2020-02-04
    17:23:47.964372943 +0100 @@ -47,7 +47,7 @@ #endif /* These tests are based
    on fpurge.c. */ -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU
    libc, BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN ||
    __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ if
    (fp->_IO_read_end == fp->_IO_read_ptr && fp->_IO_write_ptr ==
    fp->_IO_write_base && fp->_IO_save_base == NULL) @@ -121,7 +121,7 @@ return
    -1; } -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc,
    BeOS, Haiku, Linux libc5 */ +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ ==
    1 /* GNU libc, BeOS, Haiku, Linux libc5 */ fp->_flags &= ~_IO_EOF_SEEN;
    fp->_offset = pos; #elif defined __sferror || defined __DragonFly__ /*
    FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ diff -ur
    m4-1.4.17/lib/stdio-impl.h m4-1.4.17-patch/lib/stdio-impl.h ---
    m4-1.4.17/lib/stdio-impl.h 2013-09-22 08:20:02.000000000 +0200 +++
    m4-1.4.17-patch/lib/stdio-impl.h 2020-02-04 17:23:47.964372943 +0100 @@
    -18,6 +18,12 @@ the same implementation of stdio extension API, except that
    some fields have different naming conventions, or their access requires some
    casts. */ +/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around
    this + problem by defining it ourselves. FIXME: Do not rely on glibc +
    internals. */ +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN +# define
    _IO_IN_BACKUP 0x100 +#endif /* BSD stdio derived implementations. */ 
agowa338
Written by agowa338