bugmake - Bugs: bug #26887, intermediate files declared...

 
 

bug #26887: intermediate files declared INTERMEDIATE are made PRECIOUS

Submitted by:  Tim Brown <timbrown>
Submitted on:  Thu 25 Jun 2009 03:53:45 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 3.81Operating System: Any
Fixed Release: 3.82Triage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 03 Aug 2009 12:35:45 PM UTC, comment #3:

I'm not sure which bug fix resolved it, but this is currently working properly in the CVS version of GNU make.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Thu 25 Jun 2009 04:29:45 PM UTC, comment #2:

Apologies... reverse patch.

This should be better.

(file #18320)

Tim Brown <timbrown>
Thu 25 Jun 2009 04:10:57 PM UTC, comment #1:

I've written, but not thoroughly tested the attached patch.

Forgive me, but I'm not au fait with CVS etc.
(to the extent that I can't get autoconf to work on my system)
so I'll just drop the file here and if someone wants to wrestle
me into doing this properly - get in touch.

[I've just noticed that patterns aren't handled with what I've
done, so guidance here would be appreciated]

It does seem to do the trick on my test case though:

$ make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq
rm foo.rr

$ make foo.rr
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr

$ WITH_bar=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq

$ WITH_INTERMEDIATE=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq
rm foo.rr

$ WITH_bar=1 WITH_INTERMEDIATE=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq
rm foo.rr

$ WITH_INTERMEDIATE=1 make foo.rr
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr

(file #18319)

Tim Brown <timbrown>
Thu 25 Jun 2009 03:53:45 PM UTC, original submission:

According to the 3.81 documentation (Sec 10.4):

> Ordinarily, a file cannot be intermediate if it is mentioned
> in the makefile as a target or prerequisite. However, you can
> explicitly mark a file as intermediate by listing it as
> a prerequisite of the special target .INTERMEDIATE. This takes
> effect even if the file is mentioned explicitly in some other
> way.


Intermediate files are deleted when they are "mentioned in the makefile as a target or prerequisite".
(eg from attached Makefile)

$ make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq
rm foo.rr

They are not deleted when they are "mentioned...".

$ WITH_bar=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq

However, if they are explicitly mentioned as .INTERMEDIATE
(and not even "mentioned..." elsewhere, as above) - it is
kept:

$ WITH_INTERMEDIATE=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq

The following stacks all the cards against me, but if it is
"mentioned..." and INTERMEDIATE is used, the intermediate file
is left:

$ WITH_bar=1 WITH_INTERMEDIATE=1 make
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr
making target file foo.qq from intermediate foo.rr
cat foo.rr > foo.qq

If a target is explicitly mentioned as .INTERMEDIATE it is,
in fact, forced to be PRECIOUS also.

This is done by the code in: implicit.c:902 (pattern_search).
From there on, it is never made un-PRECIOUS. The test for
removal (in file.c:1051 (remove_intermediates)):
(f->dontcare || !f->precious)
clause fails, and the file isn't removed.

Is there a need in pattern_search to check to see if the target is a dependency of .INTERMEDIATE before calling it precious, as
in file.c:1051 (snap_deps)?

I would never expect a file to be .INTERMEDIATE and .PRECIOUS
(it may be intermediate and precious - that is, after all the
reason for preciousness).

After all, I would not expect to see it built (and left
un-removed) unless I actually call "make foo.rr":

$ make foo.rr
making intermediate file foo.rr from foo.xx
cat foo.xx > foo.rr

Line numbers from 3.81 source.

Possibly related to fix for Savannah bug #12267

Tested on Solaris 5.10 x86, Linux x86 2.6.18

Tim Brown <timbrown>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #18320:  Savannah.26887.gmake.implicit.c.patch-2 added by timbrown (2KiB - application/octet-stream - file #18319 is a reverse patch. Don't use it, this one should be better)
file #18319:  Savannah.26887.gmake.implicit.c.patch added by timbrown (2KiB - application/octet-stream)
file #18318:  Makefile added by timbrown (801B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by timbrown (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 28 Jul 2010 06:15:25 AM UTCpsmithFixed Release4.0=>3.82
    Mon 03 Aug 2009 12:35:45 PM UTCpsmithStatusNone=>Fixed
      Assigned toNone=>psmith
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.0
    Thu 25 Jun 2009 04:29:45 PM UTCtimbrownAttached File-=>Added Savannah.26887.gmake.implicit.c.patch-2, #18320
    Thu 25 Jun 2009 04:10:57 PM UTCtimbrownAttached File-=>Added Savannah.26887.gmake.implicit.c.patch, #18319
    Thu 25 Jun 2009 03:53:45 PM UTCtimbrownAttached File-=>Added Makefile, #18318

    Back to the top


    Powered by Savane 3.1-cleanup1