C++ Logo

SG15

Advanced search

Subject: Re: [SG15] module source suffixes
From: Ben Boeckel (ben.boeckel_at_[hidden])
Date: 2019-08-28 10:56:22


On Wed, Aug 28, 2019 at 15:24:21 -0000, "Johan Boulé" via SG15 wrote:
> Ben Boeckel wrote:
> > Remember that tools like make *assume* that if a recipe is run, its
> > specified outputs are out-of-date (there is no equivalent of ninja's
> > `restat = 1`).
>
> I can speak only for GNU's version of make, but this is not the case with
> that implementation: if the target is not changed by the recipe, it won't
> forcibly be considered out of date when used as a prerequisite of another
> target.

Going from POSIX, it seems that is allowed, but not required. There is
nothing saying that make has to do the restat. While I suspect gmake is
the most common version out there, BSD's make is also heavily used and
I'd need to check its behavior with this.

From
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
(Extended Description):

    The make utility attempts to perform the actions required to ensure
    that the specified targets are up-to-date. A target shall be
    considered up-to-date if it exists and is newer than all of its
    dependencies, or if it has already been made up-to-date by the
    current invocation of make (regardless of the target's existence or
    age). A target may also be considered up-to-date if it exists, is
    the same age as one or more of its prerequisites, and is newer than
    the remaining prerequisites (if any). The make utility shall treat
    all prerequisites as targets themselves and recursively ensure that
    they are up-to-date, processing them in the order in which they
    appear in the rule. The make utility shall use the modification
    times of files to determine whether the corresponding targets are
    out-of-date.

    To ensure that a target is up-to-date, make shall ensure that all of
    the prerequisites of a target are up-to-date, then check to see if
    the target itself is up-to-date. If the target is not up-to-date,
    the target shall be made up-to-date by executing the rule's commands
    (if any). If the target does not exist after the target has been
    successfully made up-to-date, the target shall be treated as being
    newer than any target for which it is a prerequisite.

    If a target exists and there is neither a target rule nor an
    inference rule for the target, the target shall be considered
    up-to-date. It shall be an error if make attempts to ensure that a
    target is up-to-date but the target does not exist and there is
    neither a target rule nor an inference rule for the target.

> bmi: bmi.trigger
> cp mxx $@.new # dummy precompile
> test -e $@ && cmp $@.new $@ && rm $@.new || mv -v $@.new $@
> TZ=UTC touch -t 197001010000.01 $<

This resets the time to be too old, no? Wouldn't you want to use
something like `touch -r=$@ $<` instead (though the max of all $@ is
more complicated)? With this, bmi is out-of-date after running it
because it is older than bmi.trigger.

--Ben


SG15 list run by sg15-owner@lists.isocpp.org

Older archives