bugmake - Bugs: bug #35133, Pattern rules used as dependencies...

 
 

bug #35133: Pattern rules used as dependencies for .PRECIOUS don't actually do pattern matching

Submitter:  None
Submitted:  Tue 20 Dec 2011 10:17:46 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  3.82 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 21 Dec 2011 03:54:55 PM UTC, comment #2: 

I can see where it would be an issue with backward compatibility.

At the least, .PRECIOUS should probably have a better description in the documentation to make it more clear that it will only match on a target if the patterns are identical.

Brian Vandenberg <phantal>
Tue 20 Dec 2011 11:22:06 PM UTC, comment #1: 

The .PRECIOUS pseudo-target is behaving as documented:


You can also list the target pattern of an implicit rule (such as
`%.o') as a prerequisite file of the special target `.PRECIOUS' to
preserve intermediate files created by rules whose target patterns
match that file's name.


And so are pattern-specific variable assignments:


In addition to target-specific variable values, GNU `make'
supports pattern-specific variable values.  In this form, the
variable is defined for any target that matches the pattern
specified.


This is not a bug; the system is behaving as documented.

We can consider changing the behavior of, for example, the .PRECIOUS target so that patterns simply match any target, like other pseudo-targets that take patterns, but we'd have to think very carefully about the backward-compatibility implications of this.  I'll leave this open as an enhancement request.

Paul D. Smith <psmith>
Group administrator
Tue 20 Dec 2011 10:17:46 PM UTC, original submission:  

Simple example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
all: some_target_blah.o stuff.o
  @echo $@, $<

%.y:
  @echo $@

some_target%.cc : %.y
  @echo $@, ${TEST}

%.cc:
  @echo $@, ${TEST}

%.o : %.cc
  @echo $@, $<

#1
%.cc : TEST := stuff

#2
.PRECIOUS: %.cc
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In the above example, pattern-matching is used in a few different ways; the two I'm drawing attention to in this bug report are #1 and #2.

#1 causes EVERY .cc file to have TEST set.  However, in #2, the pattern specified as a dependency of .PRECIOUS only applies to files built using a rule of the form:

%.cc : whatever

Since 'some_target_blah.o' is built using a different pattern, the .PRECIOUS directive doesn't apply to it; thus, make will still try to remove that file when it is finished running.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by phantal (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-12-20 psmith Item GroupBug Enhancement

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code