From 4c43c46d1783e49c07a627492d10ad9cb9692f28 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Thu, 21 Dec 2023 05:28:57 +0000 Subject: [PATCH 1/3] gh-112305: Fix check-clean-src to detect frozen_modules .h files. A typo left this check broken so many of us who do out-of-tree builds were seeing strange failures due to bad `Python/frozen_modules/*.h` files being picked up from the source tree and used at build time from different Python versions leading to errors like: `Fatal Python error: _PyImport_InitCore: failed to initialize importlib` Or similar once our build got to an "invoke the interpreter" bootstrapping step due to incorrect bytecode being embedded. --- Makefile.pre.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 4e2ec974b79eeaf..110bd8cee28a883 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -657,11 +657,12 @@ check-clean-src: @if test -n "$(VPATH)" -a \( \ -f "$(srcdir)/$(BUILDPYTHON)" \ -o -f "$(srcdir)/Programs/python.o" \ - -o -f "$(srcdir)\Python/frozen_modules/importlib._bootstrap.h" \ + -o -f "$(srcdir)/Python/frozen_modules/importlib._bootstrap.h" \ \); then \ echo "Error: The source directory ($(srcdir)) is not clean" ; \ echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \ - echo "Try to run: make -C \"$(srcdir)\" clean" ; \ + echo "Build artifacts such as .o files, executables, and Python/frozen_modules/*.h must not exist within $(srcdir)." ; \ + echo "Try to run: make -C \"$(srcdir)\" clean || (cd \"$(srcdir)\" && git clean -fdx)" ; \ exit 1; \ fi From 68c1bf0c6c86ff4d07fb37a81c285571e3429b7f Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Thu, 21 Dec 2023 05:35:10 +0000 Subject: [PATCH 2/3] NEWS entry. --- .../next/Build/2023-12-21-05-35-06.gh-issue-112305.VfqQPx.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2023-12-21-05-35-06.gh-issue-112305.VfqQPx.rst diff --git a/Misc/NEWS.d/next/Build/2023-12-21-05-35-06.gh-issue-112305.VfqQPx.rst b/Misc/NEWS.d/next/Build/2023-12-21-05-35-06.gh-issue-112305.VfqQPx.rst new file mode 100644 index 000000000000000..2df3207f4e6f6c9 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-12-21-05-35-06.gh-issue-112305.VfqQPx.rst @@ -0,0 +1,3 @@ +Fixed the ``check-clean-src`` step performed on out of tree builds to detect +errant ``$(srcdir)/Python/frozen_modules/*.h`` files and recommend +appropriate source tree cleanup steps to get a working build again. From 7929d36532cbfc1fb8ff2f07b3a086b3daafa431 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Thu, 21 Dec 2023 05:41:38 +0000 Subject: [PATCH 3/3] Improve the suggested cleanup command. Easily cut and pasteable on its own line, with less repetition. --- Makefile.pre.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 110bd8cee28a883..954cde8cba5bcfc 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -662,7 +662,8 @@ check-clean-src: echo "Error: The source directory ($(srcdir)) is not clean" ; \ echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \ echo "Build artifacts such as .o files, executables, and Python/frozen_modules/*.h must not exist within $(srcdir)." ; \ - echo "Try to run: make -C \"$(srcdir)\" clean || (cd \"$(srcdir)\" && git clean -fdx)" ; \ + echo "Try to run:" ; \ + echo " (cd \"$(srcdir)\" && make clean || git clean -fdx -e Doc/venv)" ; \ exit 1; \ fi