Subject: bug#48034: git coreutils ./bootstrap failure

From: Paul Eggert <[email-masked]>
Date: Tue, 27 Apr 2021 00:06:45 -0700

On 4/26/21 3:29 AM, David L. Craig wrote:

>> configure.ac:55: warning: The macro `AC_PROG_CC_STDC' is obsolete.

I reproduced these warnings; they come from Autoconf 2.71. You can 
ignore them, or you can update to the latest coreutils on Savannah, 
where I installed some patches (attached) to silence these.

>> doc/local.mk:19: installing 'build-aux/mdate-sh'
>> Makefile.am:213:   'doc/local.mk' included from here
>> doc/local.mk:19: error: required file 'build-aux/texinfo.tex' not found
>> Makefile.am:213:   'doc/local.mk' included from here

I don't observe this problem. gnulib-tool sets up a symlink that works:

$ ls -l build-aux/texinfo.tex gnulib/build-aux/texinfo.tex
lrwxrwxrwx 1 eggert eggert     31 Apr 26 23:59 build-aux/texinfo.tex -> 
../gnulib/build-aux/texinfo.tex
-rw-rw-r-- 1 eggert eggert 379274 Apr 26 23:56 gnulib/build-aux/texinfo.tex

If you still observe a problem with a fresh build from scratch, please 
investigate why gnulib-tool isn't setting up that link for you
From 1c97d9e2af40003a8ad872fb7f31d4e616f52532 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 26 Apr 2021 18:02:16 -0700
Subject: [PATCH 1/3] build: update gnulib submodule to latest

* src/csplit.c (load_buffer):
* src/pinky.c (create_fullname):
Use intprops-based checks rather than xalloc_oversized,
since Gnulib xalloc.h no longer includes xalloc-oversized.h.
---
 gnulib       | 2 +-
 src/csplit.c | 3 +--
 src/pinky.c  | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gnulib b/gnulib
index e54b645fc..354b9691a 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit e54b645fc6b8422562327443bda575c65d931fbd
+Subproject commit 354b9691accd00a531358b652689ce7f580fbe54
diff --git a/src/csplit.c b/src/csplit.c
index ee9aa6503..79bd034e3 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -518,9 +518,8 @@ load_buffer (void)
       if (lines_found || have_read_eof)
         break;
 
-      if (xalloc_oversized (2, b->bytes_alloc))
+      if (INT_MULTIPLY_WRAPV (b->bytes_alloc, 2, &bytes_wanted))
         xalloc_die ();
-      bytes_wanted = 2 * b->bytes_alloc;
       free_buffer (b);
       free (b);
     }
diff --git a/src/pinky.c b/src/pinky.c
index 23a43f5e4..6fea94923 100644
--- a/src/pinky.c
+++ b/src/pinky.c
@@ -110,9 +110,9 @@ create_fullname (char const *gecos_name, char const *user_name)
   if (ampersands != 0)
     {
       size_t ulen = strlen (user_name);
-      size_t product = ampersands * ulen;
-      rsize += product - ampersands;
-      if (xalloc_oversized (ulen, ampersands) || rsize < product)
+      size_t product;
+      if (INT_MULTIPLY_WRAPV (ulen, ampersands - 1, &product)
+          || INT_ADD_WRAPV (rsize, product, &rsize))
         xalloc_die ();
     }
 
-- 
2.27.0

From 1671951effff05096200aeb87ca6729fcccd2901 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 26 Apr 2021 20:04:19 -0700
Subject: [PATCH 2/3] csplit: size_t overflow check

* src/csplit.c (get_new_buffer): Fix unlikely size_t overflow.
---
 src/csplit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/csplit.c b/src/csplit.c
index 79bd034e3..f188e8894 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -416,7 +416,8 @@ get_new_buffer (size_t min_size)
   if (alloc_size < min_size)
     {
       size_t s = min_size - alloc_size + INCR_SIZE - 1;
-      alloc_size += s - s % INCR_SIZE;
+      if (INT_ADD_WRAPV (alloc_size, s - s % INCR_SIZE, &alloc_size))
+        xalloc_die ();
     }
 
   new_buffer = create_new_buffer (alloc_size);
-- 
2.27.0

From 96a034f490595258f9069a3fed037ddc65df2c71 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 26 Apr 2021 23:27:59 -0700
Subject: [PATCH 3/3] maint: port to Autoconf 2.71

* configure.ac: Use AC_PROG_CC, not AC_PROG_CC_STDC.
* gl/modules/smack (configure.ac):
* m4/jm-macros.m4 (coreutils_MACROS):
* m4/xattr.m4 (gl_FUNC_XATTR):
Use AS_HELP_STRING, not AC_HELP_STRING.
* m4/check-decl.m4 (gl_CHECK_DECLS):
Do not require AC_HEADER_TIME; we no longer care about it directly.
* m4/jm-macros.m4 (coreutils_MACROS):
Do not require AC_ISC_POSIX, which became obsolete in 2006.
Use AC_LINK_IFELSE instead of AC_TRY_LINK.
---
 configure.ac     |  2 +-
 gl/modules/smack |  2 +-
 m4/check-decl.m4 |  4 +---
 m4/jm-macros.m4  | 54 +++++++++++++++++++++++++++---------------------
 m4/xattr.m4      |  4 ++--
 5 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7fbecbf8d..02291a4ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,7 @@ m4_syscmd([test "${GNULIB_POSIXCHECK+set}" = set])
 m4_if(m4_sysval, [0], [], [dnl
 gl_ASSERT_NO_GNULIB_POSIXCHECK])
 
-AC_PROG_CC_STDC
+AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
diff --git a/gl/modules/smack b/gl/modules/smack
index a6dcbaa62..1c4a541a6 100644
--- a/gl/modules/smack
+++ b/gl/modules/smack
@@ -10,7 +10,7 @@ configure.ac:
 # Check whether libsmack is available
 LIB_SMACK=
 AC_ARG_ENABLE([libsmack],
-  AC_HELP_STRING([--disable-libsmack], [disable libsmack support]))
+  AS_HELP_STRING([--disable-libsmack], [disable libsmack support]))
 if test "X$enable_libsmack" != "Xno"; then
   AC_CHECK_LIB([smack], [smack_new_label_from_self],
     [AC_CHECK_LIB([smack], [smack_new_label_from_path],
diff --git a/m4/check-decl.m4 b/m4/check-decl.m4
index c67a95edb..02db0f330 100644
--- a/m4/check-decl.m4
+++ b/m4/check-decl.m4
@@ -1,4 +1,4 @@
-#serial 26
+#serial 27
 # Check declarations for this package.
 
 dnl Copyright (C) 1997-2021 Free Software Foundation, Inc.
@@ -13,8 +13,6 @@ dnl Putting it in a separate file like this helps share it between
 dnl different packages.
 AC_DEFUN([gl_CHECK_DECLS],
 [
-  AC_REQUIRE([AC_HEADER_TIME])
-
   AC_CHECK_HEADERS_ONCE([grp.h pwd.h])
   headers='
 #include <sys/types.h>
diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4
index db32cf483..fb66907f4 100644
--- a/m4/jm-macros.m4
+++ b/m4/jm-macros.m4
@@ -1,4 +1,4 @@
-#serial 112   -*- autoconf -*-
+#serial 113   -*- autoconf -*-
 
 dnl Misc type-related macros for coreutils.
 
@@ -24,9 +24,6 @@ AC_DEFUN([coreutils_MACROS],
   AM_MISSING_PROG(HELP2MAN, help2man)
   AC_SUBST([MAN])
 
-  dnl This macro actually runs replacement code.  See isc-posix.m4.
-  AC_REQUIRE([AC_ISC_POSIX])dnl
-
   gl_CHECK_ALL_TYPES
 
   AC_REQUIRE([gl_CHECK_DECLS])
@@ -116,7 +113,7 @@ AC_DEFUN([coreutils_MACROS],
   # Check whether libcap is usable -- for ls --color support
   LIB_CAP=
   AC_ARG_ENABLE([libcap],
-    AC_HELP_STRING([--disable-libcap], [disable libcap support]))
+    AS_HELP_STRING([--disable-libcap], [disable libcap support]))
   if test "X$enable_libcap" != "Xno"; then
     AC_CHECK_LIB([cap], [cap_get_file],
       [AC_CHECK_HEADER([sys/capability.h],
@@ -142,29 +139,38 @@ AC_DEFUN([coreutils_MACROS],
   # and doesn't have a separate math library.
 
   AC_SUBST([SEQ_LIBM])
-  ac_seq_body='
-     static double x, y;
-     x = floor (x);
-     x = rint (x);
-     x = modf (x, &y);'
-  AC_TRY_LINK([#include <math.h>], [$ac_seq_body], ,
-    [ac_seq_save_LIBS="$LIBS"
-     LIBS="$LIBS -lm"
-     AC_TRY_LINK([#include <math.h>], [$ac_seq_body], [SEQ_LIBM=-lm])
-     LIBS="$ac_seq_save_LIBS"
-    ])
-
+  jm_break=:
+  for jm_seqlibs in '' '-lm'; do
+    jm_seq_save_LIBS=$LIBS
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#include <math.h>
+         ]],
+         [[static double x, y;
+           x = floor (x);
+           x = rint (x);
+           x = modf (x, &y);]])],
+      [SEQ_LIBM=$jm_seqlibs
+       jm_break=break])
+    LIBS=$jm_seq_save_LIBS
+    $jm_break
+  done
 
   # See is fpsetprec() required to use extended double precision
   # This is needed on 32 bit FreeBSD to give accurate conversion of:
   # `numfmt 9223372036854775808`
-  AC_TRY_LINK([#include <ieeefp.h>],
-    [#ifdef __i386__
-      fpsetprec(FP_PE);
-     #else
-     # error not required on 64 bit
-     #endif
-    ], [ac_have_fpsetprec=yes], [ac_have_fpsetprec=no])
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM(
+       [[#include <ieeefp.h>
+       ]],
+       [[#ifdef __i386__
+          fpsetprec(FP_PE);
+         #else
+         # error not required on 64 bit
+         #endif
+       ]])],
+    [ac_have_fpsetprec=yes],
+    [ac_have_fpsetprec=no])
   if test "$ac_have_fpsetprec" = "yes" ; then
     AC_DEFINE([HAVE_FPSETPREC], 1, [whether fpsetprec is present and required])
   fi
diff --git a/m4/xattr.m4 b/m4/xattr.m4
index 3fbcd9104..5f9248939 100644
--- a/m4/xattr.m4
+++ b/m4/xattr.m4
@@ -1,5 +1,5 @@
 # xattr.m4 - check for Extended Attributes (Linux)
-# serial 3
+# serial 4
 
 # Copyright (C) 2003-2021 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -11,7 +11,7 @@
 AC_DEFUN([gl_FUNC_XATTR],
 [
   AC_ARG_ENABLE([xattr],
-        AC_HELP_STRING([--disable-xattr],
+        AS_HELP_STRING([--disable-xattr],
                        [do not support extended attributes]),
         [use_xattr=$enableval], [use_xattr=yes])
 
-- 
2.27.0