bugmake - Bugs: bug #45311, makes only one of two dependencies...

 
 

bug #45311: makes only one of two dependencies that depend on the same subdir-pattern rule

Submitted by:  Frank Heckenbach <frank>
Submitted on:  Fri 12 Jun 2015 10:55:52 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 4.1Operating System: POSIX-Based
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.

 

Sat 11 Jul 2015 09:47:59 PM UTC, comment #5:

We'd have to ask Roland or RMS; that behavior was already present when I first started using GNU make, IIRC, and I'm not sure where it originated.

I think the idea that you can generate multiple outputs with a single command is a very important capability, but I agree the current implementation (where patterns and explicit targets work in opposite ways, and you can't get the "other" way) is not ideal.

Paul D. Smith <psmith>
Project Administrator
Sat 13 Jun 2015 12:55:09 PM UTC, comment #4:

$@ wasn't the source of my confusion. Though the simplified test case would indeed have worked if $@ expanded to all targets, my actual Makefile wouldn't.

What confused me was the different behaviour of multiple-target rules with and without patterns; the former are run once for all targets, the latter once for each target. It seems quite unintuitive to me. Is there a reason for it, other than historical?

Frank Heckenbach <frank>
Sat 13 Jun 2015 04:34:54 AM UTC, comment #3:

Well, make walks targets one at a time, so there will always be a "first" target which is determined to be out of date and matches a given pattern rule, causing the recipe to fire. That target is the one that will be set with $@. The rest of the targets are marked as "also built".

I definitely wouldn't expect that $@ would contain multiple targets but maybe it's just because I'm too close :). Having something that is normally just one file be multiple files is not expected, IMO.

In general in pattern rules with multiple targets, $* is more useful than $@.

Paul D. Smith <psmith>
Project Administrator
Sat 13 Jun 2015 02:17:19 AM UTC, comment #2:

I think the confusion here has to do with the value of $@. One might reasonably expect, in a multi-target pattern rule, that $@ would be the list of all matching out-of-date targets but in fact, according to the documentation:

"In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ‘$@’ is the name of whichever target caused the rule’s recipe to be run."

Which is a bit unclear wrt the case where neither target exists, but does imply strongly that $@ will refer to just one target.

David Boyce <boyski>
Sat 13 Jun 2015 12:35:07 AM UTC, comment #1:

I may be missing something, but this looks correct to me. A pattern rule with multiple targets is different than an explicit rule with multiple targets: a pattern rule with multiple targets invokes the recipe one time and expects that to build all the targets. See the last paragraph in http://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html

As expected, make runs your recipe only one time; it expects that both targets will be created.

If there's something I'm misunderstanding please add a comment and I'll reopen the bug.

Paul D. Smith <psmith>
Project Administrator
Fri 12 Jun 2015 10:55:52 PM UTC, original submission:

% cat Makefile
all: testdir/a testdir/b
%/a %/b:; touch $@
% rm -rf testdir
% mkdir testdir
% make
touch testdir/a
% make
touch testdir/b

The first make only makes "a" and forgets "b". I wondered if my
rules are actually right like this, but since the second time
make does make "b", it seems so to me. It works as expected when
I write two separate, but identical, rules for %/a and %/b.

Frank Heckenbach <frank>

 

(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 boyski (Posted a comment)
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by frank (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
    Sat 13 Jun 2015 12:35:07 AM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1