bugmake - Bugs: bug #44783, Pattern rule redefinition are...


bug #44783: Pattern rule redefinition are silently ignored

Submitted by:  Andrey Petrov <andruxa>
Submitted on:  Thu 09 Apr 2015 01:45:06 AM UTC  
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.0 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)

You are not logged in

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


Sun 12 Jul 2015 05:41:54 PM UTC, comment #1: 

It's perfectly acceptable to have two different pattern rules for the same target and even most, but not exactly, the same prerequisites.  Consider building a .o file from a .c file, or a .cpp file, or a .f file, etc.  For prerequisites, sometimes you might require multiple prerequisites, sometimes only one.

It's true that in the situation you describe the latter rule has no effect because the first rule will always fire first.  However, make cannot know that until all the makefiles have been parsed (for example the first rule might be deleted leaving only the second one).  And in order to determine that after all makefiles have been parsed, make would have to compare each of the pattern rules against the rest of the pattern rules to see if there were duplicates.

It should be fairly straightforward to determine when an unexpected rule is being used, by use of the --trace flag or the --debug flags.

Paul D. Smith <psmith>
Project Administrator
Thu 09 Apr 2015 01:45:06 AM UTC, original submission:  

Suppose there is a Makefile:

%.o: %.c
echo building $@ from $^

%.o: %.c dummy
echo building $@ from $^

On make invocation the second rule is ignored. No warning is shown (as opposed to non-pattern rules). The latter rule has no effect

Andrey Petrov <andruxa>


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

Attach Files:

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 andruxa (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-12 psmith StatusNone => Not A Bug
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.5