bugmake - Bugs: bug #49661, syntax anomaly with order-only...

 
 

bug #49661: syntax anomaly with order-only prereqs and pattern rules

Submitter:  David Boyce <boyski>
Submitted:  Mon 21 Nov 2016 02:33:07 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 11 Jan 2017 04:03:17 PM UTC, comment #3: 

I'm going to close this.  Feel free to add comments if there is more to say.

Paul D. Smith <psmith>
Group administrator
Tue 22 Nov 2016 01:36:13 AM UTC, comment #2: 

Ah, that makes sense. I was submitting this for someone else and should have paid closer attention. Thanks.

David Boyce <boyski>
Mon 21 Nov 2016 05:53:41 PM UTC, comment #1: 

It's a important feature of pattern rules that you can define multiple pattern rules that match the same target.  Consider the various pattern rules for %.o:
$ make -pq | grep '%\.o:'
%.o:
%.o: %.c
%.o: %.cc
%.o: %.C
%.o: %.cpp
%.o: %.p
%.o: %.f
%.o: %.F
%.o: %.m
%.o: %.r
%.o: %.s
%.o: %.S
%.o: %.mod
$

In order to support that, pattern rules are independent unless they have the exact same target and prerequisite list; this lets you override or delete an existing pattern rule by defining it again.  However, it also means that prerequisite accumulation simply can't be supported for them: how would you tell make which of the existing pattern rules would you want to accumulate the prerequisites onto?

So your Makefile defines two distinct pattern rules:

$ make -pq | fgrep -C3 %.b 
#  recipe to execute (from 'Makefile', line 4):
        @echo "making $@ from '$^ | $|'"

%.b: | C

%.b: A B
#  recipe to execute (from 'Makefile', line 7):
        @echo "making $@ from '$^ | $|'"

$

You'll need to include all the prerequisites in the rule when you define it.  This perhaps may mean accumulating them into variables and only actually declaring the pattern rule using those variables once you know the prerequisites are fully calculated.


Philip Guenther

Anonymous
Mon 21 Nov 2016 02:33:07 PM UTC, original submission:  

It appears that order-only prerequisites do not accumulate for pattern targets when specified without a recipe. The test case should explain pretty clearly. Here's the makefile:

% cat Makefile
.PHONY: all
all: foo.a bar.b

%.a: A B | C
@echo "making $@ from '$^ | $|'"

%.b: | C
%.b: A B
@echo "making $@ from '$^ | $|'"

And here's the sample run:

% mkdir -p A B C

% make
making foo.a from 'A B | C'
making bar.b from 'A B | '

David Boyce <boyski>

 

(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 psmith (Posted a comment)
  • -email is unavailable- added by boyski (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-01-11 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code