bugmake - Bugs: bug #56732, VPATH doesn't work with pattern...

 
 

bug #56732: VPATH doesn't work with pattern rules

Submitter:  None
Submitted:  Thu 08 Aug 2019 11:26:35 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 27 Dec 2019 07:08:33 AM UTC, comment #4: 

This is a duplicate of bug #29104
Thanks for the report!

Paul D. Smith <psmith>
Group administrator
Sat 10 Aug 2019 03:16:22 PM UTC, comment #3: 

OK, this is a special case I didn't remembered. The wording in the manual doesn't touch implicit rules, so one can assume it should work for them too.

I don't know how much application of rules differs between normal and implicit ones, so I can't help beyond this point.

Anonymous
Fri 09 Aug 2019 10:25:27 AM UTC, comment #2: 

Thanks for looking at this. Make supports linker flags as dependencies of a recipe and automatically searches for the .a/.so file using VPATH. See the relevant section of the manual, 4.5.6 "Directory Search for Link Libraries".

I should have emphasised that this does work if it's not a pattern rule. In other words, if you replace this line:


output/% : input/%.in -lAbc


with:


output/example : input/example.in -lAbc


then the recipe works as expected (but, obviously, only for a file named "example"; unfortunately in my use case I need to build an arbitrary set of files, i.e. I need a pattern rule).

Anonymous
Thu 08 Aug 2019 02:03:57 PM UTC, comment #1: 

Your example doesn't seem to rely on VPATH in any way. Remember: VPATH is used as a place to look for files.

Also you are using "-lAbc" as prerequisite for output/%. It seems you are intending to use linker flags as input to the recipe. The way you wrote is it wrong, it will cause make to look for a file named "-lAbc" (which it won't find and abort recipe search). Run make with the flag "-d" to see makes reasoning.

Read up on using implicit rules, and the variables used for the builtin rules by make. You might want to replace "-lAbc" with  "libAbc.a" and maybe add appropriate variables if you use the built-in recipes.

Anonymous
Thu 08 Aug 2019 11:26:35 AM UTC, original submission:  

VPATH doesn't work with pattern rules, at least when using link libraries. I can see nothing in the manual to suggest it shouldn't. Here's a reduced test case.

Steps to reproduce:

In an empty directory, create the following dirs/files:

mkdir libs
touch libs/libAbc.a
mkdir input
touch input/example.in
touch input/example2.in
mkdir output


Create a Makefile with the following contents:


VPATH = libs

#irrelevant_recipe : -lAbc
#        echo "This recipe is never run"

output/% : input/%.in -lAbc
        @echo "Running recipe to build $@ from $<"



Run this command:

make output/example


Actual behaviour:


> make output/example
make: *** No rule to make target `output/example'.  Stop.


Expected behaviour:


> make output/example
Running recipe to build output/example from input/example.in


Note: Uncommenting the "irrelevant" recipe causes the pattern rule to work in the above case. However, this workaround only works for one item - if you try to build example and example2 at the same time, it still fails to build whichever one comes second. But either can be built individually:


> make output/example
Running recipe to build output/example from input/example.in
> make output/example2
Running recipe to build output/example2 from input/example2.in
> make output/example output/example2
Running recipe to build output/example from input/example.in
make: *** No rule to make target `output/example2'.  Stop.


This makes it not useful as a workaround, as really the point of pattern rules is to build multiple items using the same rule.

Anonymous

 

(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)
  •  

    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
    2019-12-27 psmith StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code