Skip to content

Commit e866eb6

Browse files
meta/Makefile: use &: for grouped targets (opencomputeproject#2200)
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.) Signed-off-by: Kaz Kylheku <[email protected]>
1 parent 401bd1f commit e866eb6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

meta/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ saiattrversion.h: $(DEPS) attrversion.sh
126126
saimetadatasize.h: $(DEPS)
127127
./size.sh
128128

129-
saimetadatatest.c saimetadata.c saimetadata.h: xml $(XMLDEPS) parse.pl $(CONSTHEADERS) $(EXTRA) saiattrversion.h
129+
saimetadatatest.c saimetadata.c saimetadata.h &: xml $(XMLDEPS) parse.pl $(CONSTHEADERS) $(EXTRA) saiattrversion.h
130130
perl -I. parse.pl
131131

132132
RPC_MODULES=$(shell find rpc -type f -name "*.pm")
133133

134-
sai.thrift sai_rpc_server.cpp sai_adapter.py: xml $(XMLDEPS) gensairpc.pl templates/*.tt $(RPC_MODULES)
134+
sai.thrift sai_rpc_server.cpp sai_adapter.py &: xml $(XMLDEPS) gensairpc.pl templates/*.tt $(RPC_MODULES)
135135
perl -Irpc gensairpc.pl $(GEN_SAIRPC_OPTS)
136136

137137
rpc: sai.thrift sai_rpc_server.cpp sai_adapter.py

0 commit comments

Comments
 (0)