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

 
 

bug #26887: intermediate files declared INTERMEDIATE are made PRECIOUS

Submitter:  Tim Brown <timbrown>
Submitted:  Thu 25 Jun 2009 03:53:45 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.81 Operating System:  Any
Fixed Release:  3.82 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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 Files:
   
   
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
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by timbrown (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-07-28 psmith Fixed Release4.0 3.82
    2009-08-03 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0
    2009-06-25 timbrown Attached File- Added Savannah.26887.gmake.implicit.c.patch-2, #18320
    2009-06-25 timbrown Attached File- Added Savannah.26887.gmake.implicit.c.patch, #18319
    2009-06-25 timbrown Attached File- Added Makefile, #18318

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code