automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: avoid a 1-second sleep in every configure script


From: Ralf Wildenhues
Subject: Re: avoid a 1-second sleep in every configure script
Date: Thu, 13 Aug 2009 23:35:34 +0200
User-agent: Mutt/1.5.20 (2009-08-09)

Hi Jim,

thanks for the patch.

* Jim Meyering wrote on Thu, Jul 30, 2009 at 04:20:52PM CEST:
> I noticed (by inspection, since I was looking at AM_SANITY_CHECK)
> the unconditional 1-second sleep in coreutils' configure script,
> and realized that it'd be easy to avoid it on modern systems:
> either because configure was created more than a second before,
> or because the file system supports subsecond time stamps.

> 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?

> +     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.

> --- a/m4/sanity.m4
> +++ b/m4/sanity.m4

>  AC_DEFUN([AM_SANITY_CHECK],
>  [AC_MSG_CHECKING([whether build environment is sane])
> -# Just in case
> -sleep 1
> +# We want conftest.file to have an mtime newer than configure.
> +# On some file systems we may have to sleep a second to ensure that.
> +# On others, with subsecond timestamp resolution, there is no need.
> +# Compare time stamps, and sleep only if a stat failed or they're identical.
>  echo timestamp > conftest.file
> +am_sleep=0
> +am_sanity_d1=`stat --format=%y conftest.file 2>/dev/null` || am_sleep=1
> +am_sanity_d2=`stat --format=%y "$srcdir/configure" 2>/dev/null` || am_sleep=1

'info Autoconf Assignments' tells me that I shouldn't rely upon the exit
status of an assignment, due to some arcane shells.  IIUC then this
should not cause a semantic change here; but that is a bit non obvious,
and makes me wonder why you need the am_sleep=1 case at all.

The other very very minor issue is that this forks twice more also on
slow-fork non-GNU systems, where it then also sleeps.  We can probably
ignore this.

> +if test $am_sleep = 1 || test "$am_sanity_d1" = "$am_sanity_d2"; then
> +   sleep 1
> +   echo timestamp > conftest.file
> +fi

Thanks,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]