meta/Makefile: use &: for grouped targets #2200
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The meta/Makefile contains several rules which are not correct for parallel make. These rules contain several targets to the left of the colon, and express the intent that the targets are built together as a group. Unfortunately, that's not what the syntax means: Rather:
t1 t2 t3 : prereq
recipe # recipe generates all three!
is essentially a syntactic sugar condensing multiple rules with the same recipe and prerequisites:
t1 : prereq
recipe # recipe generates all three!
t2 : prereq
recipe
t3 : prereq
recipe
Under parallel make these rules fire in parallel which can wreak havoc, since they stomp on each other's files.
The issue can be addressed using the grouped targets feature:
t1 t2 t3 &: prereq
recipe # recipe generates all three!
The ampersand-colon separator &: means that there is only one rule here which Make understands to be updating all three targets.
This feature has been available since GNU Make 4.2.90. Ubuntu-latest is on 4.3.
(The grouped targets feature was the subject of a bugfix before 4.4. The bug potentially causes a grouped target not to be remade if it is deleted. This is minor problem because it's not expected that someone will be deleting, say, the generated file saimetadata.c individually rather than doing a "make clean" which deletes all the generated files.)