bugmake - Bugs: bug #57692, Parallel make doesn't work well...

 
 

bug #57692: Parallel make doesn't work well with grouped targets

Submitter:  Philipp Krause <spth>
Submitted:  Wed 29 Jan 2020 10:42:26 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  None Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 11 May 2020 03:57:17 PM UTC, comment #4: 


> There is a token in .FEATURES for this capability already


Oh, pardon me, I accidentally took an old version for testing.

> Notice groupd-target here.


Splendid!

Would you care for a patch/PR of the manual explaining this, with an example (along the lines given above) of how to write a backwards-compatible rule?

Robert Sachunsky <bertsky>
Mon 11 May 2020 03:42:11 PM UTC, comment #3: 

There is a token in .FEATURES for this capability already:


$ echo '$(info $(.FEATURES))' | ./make -f-
target-specific order-only second-expansion else-if shortest-stem undefine oneshell nocomment grouped-target extra-prereqs archives jobserver output-sync check-symlink guile load maintainer
make: *** No targets.  Stop.


Notice groupd-target here.

Paul D. Smith <psmith>
Group administrator
Sun 10 May 2020 10:49:12 PM UTC, comment #2: 

Still, I believe this new syntax should really be listed in .FEATURES

That way, makefiles which want to employ this (highly valued!) new feature, can be written in a way that older versions of make can still run them.

The documentation should also reflect that, perhaps with an example like:


ifeq ($(filter grouped-targets,$(.FEATURES)),grouped-targets)
# use new syntax:
output1 output2 &: prereq
        produce -from prereq output1 output2
else
# use multi-target rule, and disable parallelism globally
.NOTPARALLEL:
endif



Robert Sachunsky <bertsky>
Wed 29 Jan 2020 12:36:54 PM UTC, comment #1: 

The entire point of grouped targets is to support parallel make properly: if you only use serial make then you don't really need them.

However, grouped targets were introduced in GNU make 4.3.  If you're using an older version, they don't exist.

In 4.2.1 and before, your makefile simply defines normal (non-grouped) targets, plus an extra target which is named, literally, "&".

Paul D. Smith <psmith>
Group administrator
Wed 29 Jan 2020 10:42:26 AM UTC, original submission:  

I use GNU make 4.2.1 (as part of Debian GNU/Linux testing); I have not checked if other versions of GNU make are affected.

I noticed that parallel make results in the rules for grouped targets being executed multiple times (for me it corrupted files by multiple processes appending to the same file simultaneously). Which is unlikely to be what users want, as it easily results in corrupted files, and is inefficient.

The following Makefile, when invoked using make -j 4 reproduces the issue (I see the text "Sleeping" four times):

RESULTS = a b c d

.PHONY: all clean

all: $(RESULTS)

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

clean:
rm -f $(RESULTS)

Philipp Krause <spth>

 

(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 bertsky (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by spth (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-01-29 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code