bug-make
[Top][All Lists]
Advanced

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

Re: make handling of prerequisites that interlock?


From: Boris Kolpackov
Subject: Re: make handling of prerequisites that interlock?
Date: Thu, 7 Apr 2005 09:03:49 +0000 (UTC)
User-agent: nn/6.6.5+RFC1522

Boris Kolpackov <address@hidden> writes:

> cat x >b    # timestamp(b) = 1
> cat b >a    # timestamp(a) = 2
> echo x >x   # timestamp(x) = 2
> cat x >b    # timestamp(b) = 2
>
>
> The code in GNU make that decides whether to print "Prerequisite `c'
> is newer than target `a'" assumes that the two consecutive modifications
> to two different files will result in two different timestamps. However
> it is not always the case: sometimes they end up having equal timestamps.
> So I would say there is a bug in that logic.

After some more thinking I believe we can easily fix this and do what
users would expect. Right now make decides whether to rebuild a target
if a timestmap of some of its prerequisites is newer than the target's.
I think it should also rebuild if the timestamps are equal and the
prerequisite has changed (i.e., before had an older timestamp). Here
is the relevant code (remake.c:check_dep):

  if (!file->intermediate)
    /* If this is a non-intermediate file, update it and record
       whether it is newer than THIS_MTIME.  */
    {
      FILE_TIMESTAMP mtime;
      dep_status = update_file (file, depth);
      check_renamed (file);
      mtime = file_mtime (file);
      check_renamed (file);
      if (mtime == NONEXISTENT_MTIME || mtime > this_mtime)
        *must_make_ptr = 1;
    }

We can change it like this:

  if (!file->intermediate)
    /* If this is a non-intermediate file, update it and record
       whether it is newer than THIS_MTIME.  */
    {
      FILE_TIMESTAMP new_mtime, old_mtime;
      old_mtime = file_mtime (file);
      dep_status = update_file (file, depth);
      check_renamed (file);
      new_mtime = file_mtime (file);
      check_renamed (file);
      if (new_mtime == NONEXISTENT_MTIME ||
          new_mtime > this_mtime ||
          new_mtime == this_mtime && new_mtime > old_mtime)
        *must_make_ptr = 1;
    }

Paul, what do you think?

-boris




reply via email to

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