Re: [PATCH] largefile: port to C++

2024-04-25 Thread Bruno Haible
Paul Eggert wrote:
> -[AC_CACHE_CHECK([for $CC option to enable large file support],
> +[AC_CACHE_CHECK([for $CPPFLAGS option for large files],

Sorry, but I find the older wording ("option to enable large file support")
more understandable than ("option for large files"). The new wording
potentially suggests that the package may _create_ huge files, dissuading
users from using this option.

> (_AC_SYS_LARGEFILE_OPTIONS): Omit -n32.

So, this means that this macro does nothing any more for IRIX. Here's a patch
to update the documentation.


2024-04-25  Bruno Haible  

largefile: Update documentation.
* doc/largefile.texi: Remove mention of IRIX.

diff --git a/doc/largefile.texi b/doc/largefile.texi
index 574753f10a..cbffee2181 100644
--- a/doc/largefile.texi
+++ b/doc/largefile.texi
@@ -6,7 +6,7 @@
 To this effect, it attempts to ensure that types like @code{off_t} and
 @code{ino_t} are 64-bit,
 at least on the following platforms:
-glibc, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, Solaris,
+glibc, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, Solaris,
 Cygwin, mingw, MSVC.
 
 If the types cannot be made 64-bit, @command{configure} issues a






Re: [PATCH] largefile: port to C++

2024-04-24 Thread Sam James
Paul Eggert  writes:

> This patch is mostly taken from Autoconf master.
> * m4/largefile.m4 (AC_SYS_YEAR2038_RECOMMENDED):
> Undefine if unpatched Autoconf 2.72 or earlier, so that
> later code will redefine it.
> The remaining part of this patch is from Autoconf master.
> (_AC_SYS_YEAR2038_PROBE, _AC_SYS_LARGEFILE_PROBE):
> Put "$CCFLAGS" in diagnostics, not "$CC".
> (_AC_SYS_LARGEFILE_OPTIONS): Omit -n32.
> (AC_SYS_LARGEFILE_PROBE): Fiddle with CPPFLAGS, not CC.
> Do not worry about -n32.
> ---
>  ChangeLog   | 12 
>  m4/largefile.m4 | 33 -

Please crank serial.

>  2 files changed, 32 insertions(+), 13 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 6564e09ac5..676aaef0be 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,17 @@
>  2024-04-24  Paul Eggert  
>  
> + largefile: port to C++
> + This patch is mostly taken from Autoconf master.
> + * m4/largefile.m4 (AC_SYS_YEAR2038_RECOMMENDED):
> + Undefine if unpatched Autoconf 2.72 or earlier, so that
> + later code will redefine it.
> + The remaining part of this patch is from Autoconf master.
> + (_AC_SYS_YEAR2038_PROBE, _AC_SYS_LARGEFILE_PROBE):
> + Put "$CCFLAGS" in diagnostics, not "$CC".
> + (_AC_SYS_LARGEFILE_OPTIONS): Omit -n32.
> + (AC_SYS_LARGEFILE_PROBE): Fiddle with CPPFLAGS, not CC.
> + Do not worry about -n32.
> +
>   c32srtombs,mbsrtoc32s,mbsrtowcs,wcsrtombs: pacify GCC 14
>   * lib/c32srtombs-state.c (_gl_c32srtombs_state):
>   * lib/mbsrtoc32s-state.c (_gl_mbsrtoc32s_state):
> diff --git a/m4/largefile.m4 b/m4/largefile.m4
> index cf97e986a3..2f824089b0 100644
> --- a/m4/largefile.m4
> +++ b/m4/largefile.m4
> @@ -26,9 +26,20 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
>   ]])
>  )
>  
> +dnl Remove AC_SYS_YEAR2038_RECOMMENDED if unpatched Autoconf 2.72 or earlier.
> +dnl Autoconf 2.72 still uses -n32, which is not a C preprocessor option,
> +dnl and which was useful only on IRIX which is no longer supported.
> +dnl This should be fixed in Autoconf 2.73.
> +m4_ifdef([AC_SYS_YEAR2038_RECOMMENDED],
> +  [m4_bmatch(m4_ifdef([_AC_SYS_LARGEFILE_OPTIONS],
> +   [m4_defn([_AC_SYS_LARGEFILE_OPTIONS])],
> +   ["-n32"]),
> + ["-n32"],
> +   [m4_undefine([AC_SYS_YEAR2038_RECOMMENDED])])])
> +
>  m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [
> -# Support AC_SYS_YEAR2038_RECOMMENDED and related macros, even if
> -# Autoconf 2.71 or earlier.  This code is taken from Autoconf master.
> +# Fix up AC_SYS_YEAR2038_RECOMMENDED and related macros, even if
> +# unpatched Autoconf 2.72 or earlier.  This code is taken from Autoconf 
> master.
>  
>  # _AC_SYS_YEAR2038_TEST_CODE
>  # --
> @@ -77,7 +88,7 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
>  # If you change this macro you may also need to change
>  # _AC_SYS_YEAR2038_OPTIONS.
>  AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
> -[AC_CACHE_CHECK([for $CC option for timestamps after 2038],
> +[AC_CACHE_CHECK([for $CPPFLAGS option for timestamps after 2038],
>[ac_cv_sys_year2038_opts],
>[ac_save_CPPFLAGS="$CPPFLAGS"
>ac_opt_found=no
> @@ -207,7 +218,6 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
>  ["none needed"]   dnl Most current systems
>  ["-D_FILE_OFFSET_BITS=64"]dnl X/Open LFS spec
>  ["-D_LARGE_FILES=1"]  dnl 32-bit AIX 4.2.1+, 32-bit z/OS
> -["-n32"]  dnl 32-bit IRIX 6, SGI cc (obsolete)
>  ))
>  
>  # _AC_SYS_LARGEFILE_PROBE
> @@ -224,25 +234,25 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
>  # If you change this macro you may also need to change
>  # _AC_SYS_LARGEFILE_OPTIONS.
>  AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
> -[AC_CACHE_CHECK([for $CC option to enable large file support],
> +[AC_CACHE_CHECK([for $CPPFLAGS option for large files],
>[ac_cv_sys_largefile_opts],
> -  [ac_save_CC="$CC"
> +  [ac_save_CPPFLAGS=$CPPFLAGS
>ac_opt_found=no
>for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
>  AS_IF([test x"$ac_opt" != x"none needed"],
> -  [CC="$ac_save_CC $ac_opt"])
> +  [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
>  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
>   [AS_IF([test x"$ac_opt" = x"none needed"],
>   [# GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t.
> -  CC="$CC -DFTYPE=ino_t"
> +  CPPFLAGS="$CPPFLAGS -DFTYPE=ino_t"
>AC_COMPIL

[PATCH] largefile: port to C++

2024-04-24 Thread Paul Eggert
This patch is mostly taken from Autoconf master.
* m4/largefile.m4 (AC_SYS_YEAR2038_RECOMMENDED):
Undefine if unpatched Autoconf 2.72 or earlier, so that
later code will redefine it.
The remaining part of this patch is from Autoconf master.
(_AC_SYS_YEAR2038_PROBE, _AC_SYS_LARGEFILE_PROBE):
Put "$CCFLAGS" in diagnostics, not "$CC".
(_AC_SYS_LARGEFILE_OPTIONS): Omit -n32.
(AC_SYS_LARGEFILE_PROBE): Fiddle with CPPFLAGS, not CC.
Do not worry about -n32.
---
 ChangeLog   | 12 
 m4/largefile.m4 | 33 -
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6564e09ac5..676aaef0be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2024-04-24  Paul Eggert  
 
+   largefile: port to C++
+   This patch is mostly taken from Autoconf master.
+   * m4/largefile.m4 (AC_SYS_YEAR2038_RECOMMENDED):
+   Undefine if unpatched Autoconf 2.72 or earlier, so that
+   later code will redefine it.
+   The remaining part of this patch is from Autoconf master.
+   (_AC_SYS_YEAR2038_PROBE, _AC_SYS_LARGEFILE_PROBE):
+   Put "$CCFLAGS" in diagnostics, not "$CC".
+   (_AC_SYS_LARGEFILE_OPTIONS): Omit -n32.
+   (AC_SYS_LARGEFILE_PROBE): Fiddle with CPPFLAGS, not CC.
+   Do not worry about -n32.
+
c32srtombs,mbsrtoc32s,mbsrtowcs,wcsrtombs: pacify GCC 14
* lib/c32srtombs-state.c (_gl_c32srtombs_state):
* lib/mbsrtoc32s-state.c (_gl_mbsrtoc32s_state):
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index cf97e986a3..2f824089b0 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -26,9 +26,20 @@ AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
  ]])
 )
 
+dnl Remove AC_SYS_YEAR2038_RECOMMENDED if unpatched Autoconf 2.72 or earlier.
+dnl Autoconf 2.72 still uses -n32, which is not a C preprocessor option,
+dnl and which was useful only on IRIX which is no longer supported.
+dnl This should be fixed in Autoconf 2.73.
+m4_ifdef([AC_SYS_YEAR2038_RECOMMENDED],
+  [m4_bmatch(m4_ifdef([_AC_SYS_LARGEFILE_OPTIONS],
+   [m4_defn([_AC_SYS_LARGEFILE_OPTIONS])],
+   ["-n32"]),
+ ["-n32"],
+   [m4_undefine([AC_SYS_YEAR2038_RECOMMENDED])])])
+
 m4_ifndef([AC_SYS_YEAR2038_RECOMMENDED], [
-# Support AC_SYS_YEAR2038_RECOMMENDED and related macros, even if
-# Autoconf 2.71 or earlier.  This code is taken from Autoconf master.
+# Fix up AC_SYS_YEAR2038_RECOMMENDED and related macros, even if
+# unpatched Autoconf 2.72 or earlier.  This code is taken from Autoconf master.
 
 # _AC_SYS_YEAR2038_TEST_CODE
 # --
@@ -77,7 +88,7 @@ m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
 # If you change this macro you may also need to change
 # _AC_SYS_YEAR2038_OPTIONS.
 AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
-[AC_CACHE_CHECK([for $CC option for timestamps after 2038],
+[AC_CACHE_CHECK([for $CPPFLAGS option for timestamps after 2038],
   [ac_cv_sys_year2038_opts],
   [ac_save_CPPFLAGS="$CPPFLAGS"
   ac_opt_found=no
@@ -207,7 +218,6 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
 ["none needed"]   dnl Most current systems
 ["-D_FILE_OFFSET_BITS=64"]dnl X/Open LFS spec
 ["-D_LARGE_FILES=1"]  dnl 32-bit AIX 4.2.1+, 32-bit z/OS
-["-n32"]  dnl 32-bit IRIX 6, SGI cc (obsolete)
 ))
 
 # _AC_SYS_LARGEFILE_PROBE
@@ -224,25 +234,25 @@ m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
 # If you change this macro you may also need to change
 # _AC_SYS_LARGEFILE_OPTIONS.
 AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
-[AC_CACHE_CHECK([for $CC option to enable large file support],
+[AC_CACHE_CHECK([for $CPPFLAGS option for large files],
   [ac_cv_sys_largefile_opts],
-  [ac_save_CC="$CC"
+  [ac_save_CPPFLAGS=$CPPFLAGS
   ac_opt_found=no
   for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
 AS_IF([test x"$ac_opt" != x"none needed"],
-  [CC="$ac_save_CC $ac_opt"])
+  [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
  [AS_IF([test x"$ac_opt" = x"none needed"],
[# GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t.
-CC="$CC -DFTYPE=ino_t"
+CPPFLAGS="$CPPFLAGS -DFTYPE=ino_t"
 AC_COMPILE_IFELSE([], [],
-  [CC="$CC -D_FILE_OFFSET_BITS=64"
+  [CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
AC_COMPILE_IFELSE([], [ac_opt='-D_FILE_OFFSET_BITS=64'])])])
   ac_cv_sys_largefile_opts=$ac_opt
   ac_opt_found=yes])
 test $ac_opt_found = no || break
   done
-  CC="$ac_save_CC"
+  CPPFLAGS=$ac_save_CPPFLAGS
   dnl Gnulib implements large file support for native Windows, based on the
   dnl variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE.