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

 
 

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

Submitted by:  David Boyce <boyski>
Submitted on:  Mon 21 Nov 2016 02:33:07 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 4.2.1Operating System: None
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

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 boyski (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 11 Jan 2017 04:03:17 PM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1