Skip to content

Commit 8c30e65

Browse files
committed
[3.11] pythongh-93584: Make all install+tests targets depends on all (pythonGH-93589)
All install targets use the "all" target as synchronization point to prevent race conditions with PGO builds. PGO builds use recursive make, which can lead to two parallel `./python setup.py build` processes that step on each others toes. "test" targets now correctly compile PGO build in a clean repo. (cherry picked from commit 243ed54) Co-authored-by: Christian Heimes <[email protected]>
1 parent 68aae80 commit 8c30e65

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Makefile.pre.in

+16-12
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ LIBEXPAT_HEADERS= \
580580

581581
# Default target
582582
all: @DEF_MAKE_ALL_RULE@
583-
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
584-
Programs/_testembed python-config
583+
build_all: check-clean-src $(BUILDPYTHON) platform oldsharedmods sharedmods \
584+
gdbhooks Programs/_testembed python-config
585585
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config
586586

587587
# Check that the source is clean when building out of source.
@@ -1671,7 +1671,7 @@ cleantest: all
16711671

16721672
# Run a basic set of regression tests.
16731673
# This excludes some tests that are particularly resource-intensive.
1674-
test: @DEF_MAKE_RULE@ platform
1674+
test: all
16751675
$(TESTRUNNER) $(TESTOPTS)
16761676

16771677
# Run the full test suite twice - once without .pyc files, and once with.
@@ -1681,7 +1681,7 @@ test: @DEF_MAKE_RULE@ platform
16811681
# the bytecode read from a .pyc file had the bug, sometimes the directly
16821682
# generated bytecode. This is sometimes a very shy bug needing a lot of
16831683
# sample data.
1684-
testall: @DEF_MAKE_RULE@ platform
1684+
testall: all
16851685
-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
16861686
$(TESTPYTHON) -E $(srcdir)/Lib/compileall.py
16871687
-find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
@@ -1690,7 +1690,7 @@ testall: @DEF_MAKE_RULE@ platform
16901690

16911691
# Run the test suite for both architectures in a Universal build on OSX.
16921692
# Must be run on an Intel box.
1693-
testuniversal: @DEF_MAKE_RULE@ platform
1693+
testuniversal: all
16941694
@if [ `arch` != 'i386' ]; then \
16951695
echo "This can only be used on OSX/i386" ;\
16961696
exit 1 ;\
@@ -1701,7 +1701,7 @@ testuniversal: @DEF_MAKE_RULE@ platform
17011701

17021702
# Like testall, but with only one pass and without multiple processes.
17031703
# Run an optional script to include information about the build environment.
1704-
buildbottest: all platform
1704+
buildbottest: all
17051705
-@if which pybuildbot.identify >/dev/null 2>&1; then \
17061706
pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
17071707
fi
@@ -1716,7 +1716,7 @@ QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
17161716
test_multiprocessing_forkserver \
17171717
test_mailbox test_nntplib test_socket test_poll \
17181718
test_select test_zipfile test_concurrent_futures
1719-
quicktest: @DEF_MAKE_RULE@ platform
1719+
quicktest: all
17201720
$(TESTRUNNER) $(QUICKTESTOPTS)
17211721

17221722
# SSL tests
@@ -1727,6 +1727,10 @@ multisslcompile: all
17271727
multissltest: all
17281728
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/ssl/multissltests.py
17291729

1730+
# All install targets use the "all" target as synchronization point to
1731+
# prevent race conditions with PGO builds. PGO builds use recursive make,
1732+
# which can lead to two parallel `./python setup.py build` processes that
1733+
# step on each others toes.
17301734
install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@
17311735
if test "x$(ENSUREPIP)" != "xno" ; then \
17321736
case $(ENSUREPIP) in \
@@ -1755,7 +1759,7 @@ commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
17551759
# Install shared libraries enabled by Setup
17561760
DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
17571761

1758-
oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
1762+
oldsharedinstall: $(DESTSHARED) all
17591763
@for i in X $(SHAREDMODS); do \
17601764
if test $$i != X; then \
17611765
echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
@@ -2161,7 +2165,7 @@ LIBPL= @LIBPL@
21612165
# pkgconfig directory
21622166
LIBPC= $(LIBDIR)/pkgconfig
21632167

2164-
libainstall: @DEF_MAKE_RULE@ python-config
2168+
libainstall: all python-config
21652169
@for i in $(LIBDIR) $(LIBPL) $(LIBPC) $(BINDIR); \
21662170
do \
21672171
if test ! -d $(DESTDIR)$$i; then \
@@ -2215,7 +2219,7 @@ libainstall: @DEF_MAKE_RULE@ python-config
22152219

22162220
# Install the dynamically loadable modules
22172221
# This goes into $(exec_prefix)
2218-
sharedinstall: sharedmods
2222+
sharedinstall: all
22192223
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
22202224
--prefix=$(prefix) \
22212225
--install-scripts=$(BINDIR) \
@@ -2445,7 +2449,7 @@ distclean: clobber
24452449
-exec rm -f {} ';'
24462450

24472451
# Check that all symbols exported by libpython start with "Py" or "_Py"
2448-
smelly: @DEF_MAKE_RULE@
2452+
smelly: all
24492453
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/smelly.py
24502454

24512455
# Find files with funny names
@@ -2480,7 +2484,7 @@ funny:
24802484
-o -print
24812485

24822486
# Perform some verification checks on any modified files.
2483-
patchcheck: @DEF_MAKE_RULE@
2487+
patchcheck: all
24842488
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
24852489

24862490
check-limited-abi: all
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Address race condition in ``Makefile`` when installing a PGO build. All
2+
``test`` and ``install`` targets now depend on ``all`` target.

0 commit comments

Comments
 (0)