Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #10537 > unrolled thread

make: Multiple targets created by single rule vs parallel make

Started byPhilipp Klaus Krause <pkk@spth.de>
First post2020-01-23 15:00 +0100
Last post2022-01-05 00:27 -0800
Articles 6 — 3 participants

Back to article view | Back to comp.programming


Contents

  make: Multiple targets created by single rule vs parallel make Philipp Klaus Krause <pkk@spth.de> - 2020-01-23 15:00 +0100
    Re: make: Multiple targets created by single rule vs parallel make David Brown <david.brown@hesbynett.no> - 2020-01-23 15:31 +0100
      Re: make: Multiple targets created by single rule vs parallel make Philipp Klaus Krause <pkk@spth.de> - 2020-01-29 11:02 +0100
    Re: make: Multiple targets created by single rule vs parallel make Philipp Klaus Krause <pkk@spth.de> - 2020-01-29 13:43 +0100
      Re: make: Multiple targets created by single rule vs parallel make David Brown <david.brown@hesbynett.no> - 2020-01-29 14:03 +0100
    Re: make: Multiple targets created by single rule vs parallel make Härra Ramob <hrramob@gmail.com> - 2022-01-05 00:27 -0800

#10537 — make: Multiple targets created by single rule vs parallel make

FromPhilipp Klaus Krause <pkk@spth.de>
Date2020-01-23 15:00 +0100
Subjectmake: Multiple targets created by single rule vs parallel make
Message-ID<r0c8ue$eui$1@solani.org>
In a Makefile, I have one rule that creates multiple targets, using the
&: feature of GNU make.

However, if I use make -j, the rule is still executed as many times as
there are targets. How can I avoid that without affecting other rules?

Philipp

[toc] | [next] | [standalone]


#10538

FromDavid Brown <david.brown@hesbynett.no>
Date2020-01-23 15:31 +0100
Message-ID<r0cana$etb$1@dont-email.me>
In reply to#10537
On 23/01/2020 15:00, Philipp Klaus Krause wrote:
> In a Makefile, I have one rule that creates multiple targets, using the
> &: feature of GNU make.
> 
> However, if I use make -j, the rule is still executed as many times as
> there are targets. How can I avoid that without affecting other rules?
> 
> Philipp
> 

I think you will have to post the makefile - or, ideally, a small sample
makefile that illustrates the effect you are seeing.  It doesn't even
need to be anything compilable.  For example, you could generate "*.2"
files from "*.1" files by "cp", generate "*.3" files from multiple "*.2"
files by "cat".  Once you have a simple sample case like that, post the
makefile here and people can try to help.

This particular newsgroup has been ruined years ago by one of the worst
scourges of Usenet, "Amine Ramdane".  But there are still sane people
lurking here who would welcome a change from that crackpot - so please
give us a nice challenge here!

[toc] | [prev] | [next] | [standalone]


#10566

FromPhilipp Klaus Krause <pkk@spth.de>
Date2020-01-29 11:02 +0100
Message-ID<r0rl86$57c$1@solani.org>
In reply to#10538
Am 23.01.20 um 15:31 schrieb David Brown:
> On 23/01/2020 15:00, Philipp Klaus Krause wrote:
>> In a Makefile, I have one rule that creates multiple targets, using the
>> &: feature of GNU make.
>>
>> However, if I use make -j, the rule is still executed as many times as
>> there are targets. How can I avoid that without affecting other rules?
>>
>> Philipp
>>
> 
> I think you will have to post the makefile - or, ideally, a small sample
> makefile that illustrates the effect you are seeing.  It doesn't even
> need to be anything compilable.  For example, you could generate "*.2"
> files from "*.1" files by "cp", generate "*.3" files from multiple "*.2"
> files by "cat".  Once you have a simple sample case like that, post the
> makefile here and people can try to help.
> 
> This particular newsgroup has been ruined years ago by one of the worst
> scourges of Usenet, "Amine Ramdane".  But there are still sane people
> lurking here who would welcome a change from that crackpot - so please
> give us a nice challenge here!
> 

Here is a simple example Makefile to reproduce the issue. When I invoke
it using make -j 4, I see the poutput "sleeping" 4 times. For this
simple example, it is just an inefficientcy, however for my real use
case it results in multiple processes writing appending to the same
file, and messing up the contents.
I use GNU Make 4.2.1.


RESULTS = a b c d

.PHONY: all clean

all: $(RESULTS)

$(RESULTS) &:
	echo "Sleeping"; sleep 1;
	touch $(RESULTS)

clean:
	rm -f $(RESULTS)

[toc] | [prev] | [next] | [standalone]


#10567

FromPhilipp Klaus Krause <pkk@spth.de>
Date2020-01-29 13:43 +0100
Message-ID<r0rul2$bi2$1@solani.org>
In reply to#10537
Am 23.01.20 um 15:00 schrieb Philipp Klaus Krause:
> In a Makefile, I have one rule that creates multiple targets, using the
> &: feature of GNU make.
> 
> However, if I use make -j, the rule is still executed as many times as
> there are targets. How can I avoid that without affecting other rules?
> 
> Philipp
> 

As can be seen in

https://savannah.gnu.org/bugs/?57692

the mistake was on my side, assuming that grouped targets were supported
by GNU mmake 4.2.1. The syntax for grouped targets actually is also
valid make syntax for older versions of make, but has different
semantics there.

[toc] | [prev] | [next] | [standalone]


#10568

FromDavid Brown <david.brown@hesbynett.no>
Date2020-01-29 14:03 +0100
Message-ID<r0rvqp$beh$1@dont-email.me>
In reply to#10567
On 29/01/2020 13:43, Philipp Klaus Krause wrote:
> Am 23.01.20 um 15:00 schrieb Philipp Klaus Krause:
>> In a Makefile, I have one rule that creates multiple targets, using the
>> &: feature of GNU make.
>>
>> However, if I use make -j, the rule is still executed as many times as
>> there are targets. How can I avoid that without affecting other rules?
>>
>> Philipp
>>
> 
> As can be seen in
> 
> https://savannah.gnu.org/bugs/?57692
> 
> the mistake was on my side, assuming that grouped targets were supported
> by GNU mmake 4.2.1. The syntax for grouped targets actually is also
> valid make syntax for older versions of make, but has different
> semantics there.
> 

Thanks for posting that followup - I'm glad you figured out your problem.

[toc] | [prev] | [next] | [standalone]


#14417

FromHärra Ramob <hrramob@gmail.com>
Date2022-01-05 00:27 -0800
Message-ID<1f8b1957-b727-4c97-bb50-c50c67953ef9n@googlegroups.com>
In reply to#10537
Hey......

Wanna be friends ?

 🙂

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web