Hi Karl,

Karl Berry wrote:
> Sorry, but I don't really understand your patch. With it, it would seem
> that _AM_FILESYSTEM_TIMESTAMP_RESOLUTION is only called if the build
> environment is not "sane", i.e., a created file is not newer than
> configure. Is that right?

Yes, that's the intent — for packages other than Automake.

>     is in _AM_FILESYSTEM_TIMESTAMP_RESOLUTION, whose sole purpose is to
>     determine a variable am_cv_filesystem_timestamp_resolution. The sole
>     use of this variable is in AM_SANITY_CHECK, 
> 
> The timestamp resolution also used in Automake's t/ax/test-defs.in
> (->.sh), and Automake's configure.ac, aka MTIME_RESOLUTION. With your
> patch, how does it ever get defined?

Oops, I focused on the generated configure script and forgot to run
"make check" of Automake... Sorry about that.

Find here attached a revised proposed patch.

> Did you intend that Automake's configure.ac would then explicitly call
> _AM_FILESYSTEM_TIMESTAMP_RESOLUTION (in which case it should probably be
> renamed without a leading underscore)

Yes, this is how it should work. I've now included the renaming in the patch.

With this modification of configure.ac, MTIME_RESOLUTION is the value
of am_cv_filesystem_timestamp_resolution. I don't see any purpose any
more in a couple of lines of test-defs.in, so I removed these lines.
Please double-check; is there something I missed?

With this patch, Automake's "make check" passes, except for a test failure
in t/instdir-ltlib.sh that Paul introduced a couple of days ago:
https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commit;h=1d35638b23e95fe6f41c828a3442f6d7f242f4c4

Bruno
>From 5c601af4d9e8e4dc3ded722e8315e662b98200a4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 13 Jun 2024 13:47:49 +0200
Subject: [PATCH] automake: Save up to 2 seconds of configure time.

* m4/sanity.m4 (AM_FILESYSTEM_TIMESTAMP_RESOLUTION): Renamed from
_AM_FILESYSTEM_TIMESTAMP_RESOLUTION. Suggested by Karl Berry.
(AM_SANITY_CHECK): Don't require
_AM_FILESYSTEM_TIMESTAMP_RESOLUTION. Instead, execute it only when it is
actually needed. In most cases outside Automake's test suite, it is not
needed.
* configure.ac: Invoke AM_FILESYSTEM_TIMESTAMP_RESOLUTION.
* t/ax/test-defs.in: Don't access
$am_cv_filesystem_timestamp_resolution. Instead, rely on
MTIME_RESOLUTION.
---
 configure.ac      |  1 +
 m4/sanity.m4      | 14 +++++++++++---
 t/ax/test-defs.in | 14 ++------------
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3ff08e9f2..082d8bddb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,7 @@ AC_PROG_FGREP
 # The test suite needs to know the resolution of timestamps
 # supported by the filesystem hosting the build.  The value
 # will be acceptable to 'sleep' on this system.
+AM_FILESYSTEM_TIMESTAMP_RESOLUTION
 MTIME_RESOLUTION=$am_cv_filesystem_timestamp_resolution
 if test -z "$MTIME_RESOLUTION"; then
   AC_MSG_NOTICE(am_cv_filesystem_timestamp_resolution strangely not set; using 1)
diff --git a/m4/sanity.m4 b/m4/sanity.m4
index 68fbf36f7..2a89eb509 100644
--- a/m4/sanity.m4
+++ b/m4/sanity.m4
@@ -15,7 +15,7 @@ AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=true],
                                  [am_cv_sleep_fractional_seconds=false])
 ])])
 
-# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION
+# AM_FILESYSTEM_TIMESTAMP_RESOLUTION
 # -----------------------------------
 # Determine the filesystem's resolution for file modification
 # timestamps.  The coarsest we know of is FAT, with a resolution
@@ -25,7 +25,7 @@ AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=true],
 # possible to delay execution of a shell script for less than one
 # millisecond, due to process creation overhead and scheduling
 # granularity, so we don't check for anything finer than that. (See below.)
-AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl
+AC_DEFUN([AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl
 AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS])
 AC_CACHE_CHECK([filesystem timestamp resolution],
                am_cv_filesystem_timestamp_resolution, [dnl
@@ -141,7 +141,7 @@ rm -f conftest.ts?
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
-[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION])
+[
 # This check should not be cached, as it may vary across builds of
 # different projects.
 AC_MSG_CHECKING([whether build environment is sane])
@@ -179,6 +179,14 @@ for am_try in 1 2; do
     am_build_env_is_sane=yes
     break
   fi
+  # Determine am_cv_filesystem_timestamp_resolution. Do it only on the first
+  # loop round, since it is expensive. Do so without visible output, because
+  # we're already in a AC_MSG_CHECKING..AC_MSG_RESULT block.
+  if test $am_try = 1; then
+    exec 9>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
+    AM_FILESYSTEM_TIMESTAMP_RESOLUTION
+    exec AS_MESSAGE_FD>&9 9>&-
+  fi
   # Just in case.
   sleep $am_cv_filesystem_timestamp_resolution
   am_has_slept=yes
diff --git a/t/ax/test-defs.in b/t/ax/test-defs.in
index 61a88110e..6f0205d90 100644
--- a/t/ax/test-defs.in
+++ b/t/ax/test-defs.in
@@ -191,18 +191,8 @@ case $MTIME_RESOLUTION in
        $AUTOM4TE --version 2>&1 |
          grep 'Features:.*subsecond-mtime' > /dev/null 2>&1; then
       # subsecond-mtime should be supported; use the timestamp
-      # resolution that we determined. If it hasn't been determined,
-      # that's a bug somewhere.
-      if test -n "$am_cv_filesystem_timestamp_resolution"; then
-        #echo "$me: got $am_cv_filesystem_timestamp_resolution" >&2
-        MTIME_RESOLUTION=$am_cv_filesystem_timestamp_resolution
-      else
-        # ends up in test-suite.log.
-        echo "$me: subsecond-mtime supported per automake and auto4mte" \
-             "--version, but am_cv_filesystem_timestamp_resolution not set;" \
-             "that's an error somewhere. Proceeding with value 1." >&2
-        MTIME_RESOLUTION=1
-      fi
+      # resolution that we determined.
+      :
     else
       #echo "$me: --version doesn't support subsecond-mtime" >&2
       #$AUTOMAKE --version >&2
-- 
2.34.1

Reply via email to