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


Groups > comp.programming > #10566

Re: make: Multiple targets created by single rule vs parallel make

From Philipp Klaus Krause <pkk@spth.de>
Newsgroups comp.programming
Subject Re: make: Multiple targets created by single rule vs parallel make
Date 2020-01-29 11:02 +0100
Organization solani.org
Message-ID <r0rl86$57c$1@solani.org> (permalink)
References <r0c8ue$eui$1@solani.org> <r0cana$etb$1@dont-email.me>

Show all headers | View raw


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)

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web