Dear make maintainer,

I am a happy user of make (various implementations) for 25 years. Today I 
learned that "multiple target rules" don't do what I thought they do. 
While dealing with this, I think I've found a bug, either in code or in 
documentation. Plus I have a related suggestion for the doc.


1. multi target with "&:" ran twice

Attached is a minimal test case. When run with -j2, it executes the "foo1 
foo2" rule twice, in parallel. The related documentation is:

https://www.gnu.org/software/make/manual/make.html#Multiple-Targets

Section "Rules with Grouped Targets" says: "When make builds any one of 
the grouped targets, it understands that all the other targets in the 
group are also updated as a result of the invocation of the recipe. 
Furthermore, if only some of the grouped targets are out of date or 
missing make will realize that running the recipe will update all of the 
targets."

This suggests GNU make would understand that both foo1 and foo2 will be 
produced by the rule, which implies it wouldn't run it twice, in parallel.

Since the attached test case does run it twice in parallel, I think it's 
either a bug in the implementation or in the documentation


2. Doc clarification in the normal ":" syntax

It was entirely my fault that I misunderstood what a multiple target rule 
with the plain ":" separator would do. While initially searching the web 
for why my ":" multi target rule ran parallel, I found some other users 
had similar problems.

I think it's generally surprising that with the plain ":" syntax multi 
target rules won't get Make to understand that all targets are created. 
The documentation is clear about this in an implicit way, but I had to 
read it multiple times to make sure.

Would it be possible to mention this explicitly in the doc?


Thank you in advance,

Tibor 'Igor2' Palinkas
all: bar1 bar2

foo1 foo2 &:
        date > foo1
        sleep 1
        date > foo2

bar1: foo1 foo2
        cat foo1 foo2 > bar1

bar2: foo1 foo2
        cat foo1 foo2 > bar2

clean:
        rm foo1 foo2 bar1 bar2

Reply via email to