GNU bug report logs -
#61240
improve high-res file timestamp in Automake
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Thu, 2 Feb 2023 22:26:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 61240 <at> debbugs.gnu.org (full text, mbox):
Paul Eggert wrote:
> On 2023-02-03 18:27, Jacob Bachmeyer wrote:
>> Where are you actually using a 5.10 feature?
>
> Where lib/Automake/FileUtils.pm says "use Time::HiRes qw(stat);". This
> does not work with Perl 5.6.
Time::HiRes is (perhaps was) installable from CPAN and is definitely
/not/ a 5.10 feature. I have a Perl 5.8 with it installed, and while my
memories that far back are a bit fuzzy, I seem to remember installing
Time::HiRes on a Perl 5.6 installation some years ago. Things like
"our" variables, PerlIO-by-default, and the defined-or operator are Perl
features (those in 5.6, 5.8, and 5.10 if I remember correctly), modules
are (with rare exceptions) not Perl features.
The correct solution if you do not want to provide for the case where
Time::HiRes is not available is to simply "use Time::HiRes qw(stat);"
and *let* *that* *fail* if Time::HiRes is not available or cannot export
stat(). Time::HiRes was on CPAN long before it was bundled with Perl,
so the Perl version does /not/ tell you if it is available. (If
Automake::FileUtils is not immediately loaded, put "use Time::HiRes;"
somewhere that is. That will be enough to ensure that Time::HiRes is
available.)
> For why we bumped the version to 5.10, please see:
>
> https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=61901a1a14fd50c03cfb1529d091554376fef286
>
>
>> Please do not arbitrarily bump version requirements just to bump
>> version requirements.
>
> That's not what was done here. The abovementioned URL says version
> requirements were bumped from 5.6 to 5.10 because the feature is not
> present in 5.6 (2000), is present in 5.10 (2007), and we lacked access
> to the museum pieces in the middle. If you are sure that a version
> number lower than 5.10 will do, please let us know.
This was arbitrary because Time::HiRes is not actually dependent on the
Perl version in that way. (You should also be able to get access to the
museum pieces in the middle fairly easily using perlbrew.)
I am fairly sure that Time::HiRes could be installed from CPAN on at
least Perl 5.6 and later, and possibly even on Perls older than 5.6.
(To add it to a 5.6 installation today may require retrieving it from
BackPAN.) I definitely know that it can be installed on 5.8, as I still
have a Perl 5.8 that has it, and "use Time::HiRes qw(stat);" succeeds in
that Perl. If the requirement is Time::HiRes, then the proper course of
action is to "require Time::HiRes;" rather than requiring some version
of Perl that you know shipped it as a core module. Doing the latter
/is/ arbitrarily bumping the version requirement.
In fact, according to my copy of Module::CoreList (or, to be precise,
its corelist(1) command-line frontend), Time::HiRes was first bundled
with Perl 5.7.3. Note that I ran that query against a Perl 5.34
installation; the Perl community takes backwards compatibility like this
very seriously. Note also that I said "bundled"; it could be installed
from CPAN in older Perls, so requiring 5.8 (since 5.7 was a development
series) is /not/ correct here.
There are also the no-runtime-overhead options of using "eval { use
Time::HiRes qw(stat) };" which will replace stat() with the hi-res
version if it is available and continue with the regular stat() builtin
if not, or "use constant HAVE_Time_HiRes => eval { use Time::HiRes };"
and a conditional "if (HAVE_Time_HiRes) { ... } else { ... }" as I
suggested as an improvement to Mike Frysinger's patch.
In any case, you will still need to account for the possibility that
Time::HiRes::stat() might not actually have higher resolution, depending
on the filesystem. FAT, in particular, is notorious for its 2-second
timestamp resolution. (This issue is actually mentioned in the
Time::HiRes::stat documentation.)
-- Jacob
This bug report was last modified 2 years and 58 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.