bugmake - Bugs: bug #58639, Shortest stem not matched

 
 

bug #58639: Shortest stem not matched

Submitter:  Miles <milesf>
Submitted:  Sun 21 Jun 2020 10:39:50 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
   

Mon 07 Dec 2020 06:06:19 AM UTC, comment #3: 

I changed the text like this; hopefully it's more understandable now:


 target pattern that matches the file name, @emph{and} all
 prerequisites in that rule either exist or can be built.  The rules
 you write take precedence over those that are built in. Note however,
-that a rule whose prerequisites actually exist or are mentioned always
-takes priority over a rule with prerequisites that must be made by
-chaining other implicit rules.
+that a rule which can be satisfied without chaining other implicit
+rules (for example, one which has no prerequisites or its
+prerequisites already exist or are mentioned) always takes priority
+over a rule with prerequisites that must be made by chaining other
+implicit rules.


Paul D. Smith <psmith>
Group administrator
Sun 28 Jun 2020 10:01:10 PM UTC, comment #2: 

Paul, do you think we can describe this scenario this explicitly in the doc?
E.g.

diff --git a/doc/make.texi b/doc/make.texi
index 733c0b9..9c625d7 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -10342,9 +10342,9 @@ A pattern rule can be used to build a given file only if there is a
 target pattern that matches the file name, @emph{and} all
 prerequisites in that rule either exist or can be built.  The rules
 you write take precedence over those that are built in. Note however,
-that a rule whose prerequisites actually exist or are mentioned always
-takes priority over a rule with prerequisites that must be made by
-chaining other implicit rules.
+that a rule whose prerequisites actually exist or are mentioned or
+which has no prerequisites always takes priority over a rule with
+prerequisites that must be made by chaining other implicit rules.
 
 @cindex stem, shortest
 It is possible that more than one pattern rule will meet these

Dmitry Goncharov <dgoncharov>
Sun 21 Jun 2020 11:06:36 PM UTC, comment #1: 

Sorry, when I suggested this might be a bug I didn't read your question carefully and was confused about exactly what the problem is.  That was totally my fault, I apologize :(,

This is actually not a bug, because of this statement in the documentation: https://www.gnu.org/software/make/manual/html_node/Pattern-Match.html

> Note however, that a rule whose prerequisites actually exist or are mentioned always takes priority over a rule with prerequisites that must be made by chaining other implicit rules.


Even though your foo/% doesn't have prerequisites that counts as "a rule whose prerequisites actually exist".

Paul D. Smith <psmith>
Group administrator
Sun 21 Jun 2020 10:39:50 PM UTC, original submission:  

With this makefile:


foo/%/baz:
    @echo "Prereq - stem $*"

foo/%/baz/thing.txt: foo/%/baz
    @echo "Good match - stem $*"

foo/%:
    @echo "Bad match - stem $*"


I'd expect the shortest stem (bar) to be matched as follows:


> make foo/bar/baz/thing.txt
Prereq - stem bar
Good match - stem bar


However, it matches the longer stem (bar/baz/thing.txt) instead:


> make foo/bar/baz/thing.txt
Bad match - stem bar/baz/thing.txt


The makefile works as expected if either removing the "Bad match" rule or the prerequisite from the "Good match" rule.

Miles <milesf>

 

(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 dgoncharov (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by milesf (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
    2020-06-21 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code