diff options
author | Zack Weinberg <zack@owlfolio.org> | 2022-12-24 23:24:51 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-12-25 11:04:20 -0800 |
commit | cf09f48841b66fe76f606dd6018bb3a93242a7c9 (patch) | |
tree | 0c37133d949cc8d737783e58445119460a643ce1 /lib/autoconf/functions.m4 | |
parent | bb7c8cbb0a620157a031540ff88bc12cbcb4d0c1 (diff) | |
download | autoconf-cf09f48841b66fe76f606dd6018bb3a93242a7c9.tar.gz |
AC_SYS_LARGEFILE: Don’t enlarge time_t by default
Having AC_SYS_LARGEFILE enlarge time_t means that any program that has
already requested large file support will be abruptly migrated to
64-bit time_t (on 32-bit systems) as soon as its configure script is
regenerated with a sufficiently new Autoconf. We’ve received reports
of several widely used programs and libraries that are not prepared
for this migration, with breakage ranging from annoying (garbage
timestamps in messages) through serious (binary compatibility break
in security-critical shared library) to catastrophic (on-disk data
corruption).
Partially revert f6657256a37da44c987c04bf9cd75575dfca3b60: in the
absence of AC_SYS_YEAR2038, AC_SYS_LARGEFILE will now only add an
--enable-year2038 command line option to configure. If this option is
used, time_t will be enlarged, allowing people to experiment with the
migration without needing to *edit* the configure script in question,
only regenerate it.
In the process, AC_SYS_LARGEFILE and AC_SYS_YEAR2038 were drastically
overhauled for modularity; it should now be much easier to add support
for platforms that offer large off_t / time_t but not with the standard
feature selection macros. Also, new macros AC_SYS_LARGEFILE_REQUIRED and
AC_SYS_YEAR2038_REQUIRED can be used by programs for which large off_t /
time_t are essential.
The implementation is a little messy because it needs to gracefully
handle the case where AC_SYS_LARGEFILE and AC_SYS_LARGEFILE_REQUIRED
are both used in the same configure script — or, probably more common,
AC_SYS_LARGEFILE (which invokes _AC_SYS_YEAR2038_OPT_IN) followed by
AC_SYS_YEAR2038 — but if macro B is invoked after macro A, there’s no
way for B to change *what macro A expanded to*. The best kludge I
managed to find is to AC_CONFIG_COMMANDS_PRE as a m4-level hook that
sets shell variables in an early diversion.
* lib/autoconf/functions.m4 (AC_FUNC_FSEEKO): Rewrite to avoid dependency
on internal subroutines of AC_SYS_LARGEFILE.
* lib/autoconf/specific.m4 (_AC_SYS_YEAR2038_TEST_INCLUDES): Renamed to
_AC_SYS_YEAR2038_TEST_CODE.
(_AC_SYS_YEAR2038): Refactor into subroutines: _AC_SYS_YEAR2038_OPTIONS,
_AC_SYS_YEAR2038_PROBE, _AC_SYS_YEAR2038_ENABLE.
(AC_SYS_YEAR2038): Update for refactoring.
(_AC_SYS_YEAR2038_OPT_IN): New sorta-top-level macro, for use by
AC_SYS_LARGEFILE, that probes for large time_t only if the
--enable-year2038 option is given.
(AC_SYS_YEAR2038_REQUIRED): New top-level macro that insists on
support for large time_t.
(_AC_SYS_LARGEFILE_TEST_INCLUDES): Renamed to _AC_SYS_LARGEFILE_TEST_CODE.
(_AC_SYS_LARGEFILE_MACRO_VALUE, AC_SYS_LARGEFILE): Refactor along same
lines as above: _AC_SYS_LARGEFILE_OPTIONS, _AC_SYS_LARGEFILE_PROBE,
_AC_SYS_LARGEFILE_ENABLE. Invoke _AC_SYS_YEAR2038_OPT_IN at end of
_AC_SYS_LARGEFILE_PROBE. MinGW-specific logic moved to YEAR2038
macros as it has nothing to do with large file support.
(AC_SYS_LARGEFILE_REQUIRED): New top-level macro that insists on
support for large off_t.
* tests/local.at (_AT_CHECK_ENV): Also allow changes in CPPFLAGS,
enableval, enable_*, withval, with_*.
* doc/autoconf.texi, NEWS: Update documentation to match above changes.
Fix typo in definition of @dvarv.
Diffstat (limited to 'lib/autoconf/functions.m4')
-rw-r--r-- | lib/autoconf/functions.m4 | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 110e2f05..3dbeae79 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -641,35 +641,57 @@ AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH]) AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH]) +# _AC_FUNC_FSEEKO_TEST_PROGRAM +# ---------------------------- +# Test code used by AC_FUNC_FSEEKO. +m4_define([_AC_FUNC_FSEEKO_TEST_PROGRAM], +[AC_LANG_PROGRAM([[ +#if defined __hpux && !defined _LARGEFILE_SOURCE +# include <limits.h> +# if LONG_MAX >> 31 == 0 +# error "32-bit HP-UX 11/ia64 needs _LARGEFILE_SOURCE for fseeko in C++" +# endif +#endif +#include <sys/types.h> /* for off_t */ +#include <stdio.h> +]], [[ + int (*fp1) (FILE *, off_t, int) = fseeko; + off_t (*fp2) (FILE *) = ftello; + return fseeko (stdin, 0, 0) + && fp1 (stdin, 0, 0) + && ftello (stdin) >= 0 + && fp2 (stdin) >= 0; +]])]) + # AC_FUNC_FSEEKO # -------------- +# Check for correctly prototyped declarations of fseeko and ftello; +# define HAVE_FSEEKO if they are available. If it is necessary to +# define _LARGEFILE_SOURCE=1 to make these declarations available, +# do that (this is needed on 32-bit HP/UX). We used to try defining +# _XOPEN_SOURCE=500 too, to work around a bug in glibc 2.1.3, but that +# breaks too many other things. If you want fseeko and ftello with +# glibc, upgrade to a fixed glibc. AN_FUNCTION([ftello], [AC_FUNC_FSEEKO]) AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO]) AC_DEFUN([AC_FUNC_FSEEKO], -[_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, - [ac_cv_sys_largefile_source], - [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).], - [[#if defined __hpux && !defined _LARGEFILE_SOURCE - #include <limits.h> - #if LONG_MAX >> 31 == 0 - #error "32-bit HP-UX 11/ia64 needs _LARGEFILE_SOURCE for fseeko in C++" - #endif - #endif - #include <sys/types.h> /* for off_t */ - #include <stdio.h>]], - [[int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]]) - -# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug -# in glibc 2.1.3, but that breaks too many other things. -# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. -if test $ac_cv_sys_largefile_source != unknown; then - AC_DEFINE(HAVE_FSEEKO, 1, - [Define to 1 if fseeko (and presumably ftello) exists and is declared.]) -fi +[AC_CACHE_CHECK([for declarations of fseeko and ftello], + [ac_cv_func_fseeko_ftello], + [AC_COMPILE_IFELSE([_AC_FUNC_FSEEKO_TEST_PROGRAM], + [ac_cv_func_fseeko_ftello=yes], + [ac_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE=1" + AC_COMPILE_IFELSE([_AC_FUNC_FSEEKO_TEST_PROGRAM], + [ac_cv_func_fseeko_ftello="need _LARGEFILE_SOURCE"], + [ac_cv_func_fseeko_ftello=no])])]) +AS_IF([test "$ac_cv_func_fseeko_ftello" != no], + [AC_DEFINE([HAVE_FSEEKO], [1], + [Define to 1 if fseeko (and ftello) are declared in stdio.h.])]) +AS_IF([test "$ac_cv_func_fseeko_ftello" = "need _LARGEFILE_SOURCE"], + [AC_DEFINE([_LARGEFILE_SOURCE], [1], + [Define to 1 if necessary to make fseeko visible.])]) ])# AC_FUNC_FSEEKO - # AC_FUNC_GETGROUPS # ----------------- # Try to find 'getgroups', and check that it works. |