Hello Jim, * Jim Meyering wrote on Fri, Aug 14, 2009 at 09:33:11AM CEST: > Ralf Wildenhues wrote: > > * Jim Meyering wrote on Thu, Jul 30, 2009 at 04:20:52PM CEST: > >> I deliberately chose not to use ls, because parsing > >> its output is not worth the trouble. > > > > Could that bring any more portability though? IOW, is there a portable > > (not limited to coreutils) way to get at subsecond time stamps?
> You can get subsecond time stamps via GNU ls' --full-time option, > but if you have that version of ls, you probably also have coreutils' > stat program. If you really want to go for it, Perl is probably the > most portable tool. I haven't tried. After all, it's just 1 second, > and not worth the added complexity. Most likely, perl will not be used anywhere else in the configure script, so starting it cold-cache will not only bring in a new dependency (thus source of errors), but also likely a delay that could be in the second-range, too. > >From 3cb8feacb35d9a547fb5bf36ce1feab706aff063 Mon Sep 17 00:00:00 2001 > From: Jim Meyering <meyer...@redhat.com> > Date: Thu, 30 Jul 2009 15:55:04 +0200 > Subject: [PATCH] AM_SANITY_CHECK: avoid a 1-second sleep, if possible > > * m4/sanity.m4 (AM_SANITY_CHECK): Use stat to compare timestamps. > Perform the 1-second sleep only if necessary. Thanks. Note that with some shells, an error about the 'stat' program not existing will escape the 2>/dev/null unless you use '(stat ... ) 2>/dev/null'; so it also needs subshell here to avoid ugly configure output in that case. However, after putting this patch off for some days, I'm finally aware of what really bothers me about it: we use a nonstandard tool (stat) here that we really have no idea about what it does on other systems. It might not exist (which would be benign), but it also might be some completely unrelated tool (and the GCS don't recommend us doing that). The BSDs and IRIX have 'stat' but it doesn't provide the option the patch uses. I think we can fix most instances of this wait portably, without looking at subsecond time stamps: let's just try without sleeping first, and only if that fails, try again after sleeping. What do you think about the patch below (diff -w shown only, due to large reindentation)? Only missing bit still is a good testsuite addition to ensure that it still catches messed-up time stamps. Thanks, Ralf Avoid sleeping for one second most of the time in sanity check. * m4/sanity.m4 (AM_SANITY_CHECK): Report and different patch by Jim Meyering. diff --git a/m4/sanity.m4 b/m4/sanity.m4 index 3d2f304..b379528 100644 --- a/m4/sanity.m4 +++ b/m4/sanity.m4 @@ -1,21 +1,18 @@ # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 +# serial 6 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -35,6 +32,8 @@ esac # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( + for am_try in 1 2; do + echo timestamp > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. @@ -51,7 +50,10 @@ if ( AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi - + test "$[2]" = conftest.file && break + # Just in case. + sleep 1 + done test "$[2]" = conftest.file ) then