Skip to content

Commit 7145bd6

Browse files
itamaroclaude
andcommitted
gh-119696: Fix a parallel make race when generating the installed pkg-config files
Misc/python-install.pc and Misc/python-embed-install.pc were two targets of one rule whose recipe wrote both files, so a parallel "make install" could run the recipe twice at once and fail in cp with "File exists". Give each file its own rule that writes only that file. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 5dbe2ac commit 7145bd6

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎Makefile.pre.in‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,20 +2947,24 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
29472947
# With --enable-relocatable, the installed pkg-config files define prefix
29482948
# relative to their own location, when the pkgconfig directory is inside
29492949
# the prefix.
2950-
Misc/python-install.pc Misc/python-embed-install.pc: Misc/python.pc Misc/python-embed.pc
2950+
INSTALL_PC= \
29512951
rel=; dir='$(LIBPC)'; \
29522952
if test "$(RELOCATABLE)" = yes; then \
29532953
while test "$$dir" != '$(prefix)' && test "$$dir" != /; do \
29542954
rel="$$rel/.."; dir=`dirname "$$dir"`; \
29552955
done; \
29562956
fi; \
2957-
for pc in python python-embed; do \
2958-
if test "$$dir" = '$(prefix)'; then \
2959-
sed "s|^prefix=.*|prefix=\$${pcfiledir}$$rel|" Misc/$$pc.pc > Misc/$$pc-install.pc; \
2960-
else \
2961-
cp Misc/$$pc.pc Misc/$$pc-install.pc; \
2962-
fi; \
2963-
done
2957+
if test "$$dir" = '$(prefix)'; then \
2958+
sed "s|^prefix=.*|prefix=\$${pcfiledir}$$rel|" $< > $@; \
2959+
else \
2960+
cp $< $@; \
2961+
fi
2962+
2963+
Misc/python-install.pc: Misc/python.pc
2964+
$(INSTALL_PC)
2965+
2966+
Misc/python-embed-install.pc: Misc/python-embed.pc
2967+
$(INSTALL_PC)
29642968

29652969
# macOS' make seems to ignore a dependency on a
29662970
# "$(BUILD_SCRIPTS_DIR): $(MKDIR_P) $@" rule.

0 commit comments

Comments
 (0)