This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Patch to require Python 3.4 or later to build glibc
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Fri, 12 Oct 2018 15:59:41 +0000
- Subject: Patch to require Python 3.4 or later to build glibc
This patch, relative to a tree with
<https://sourceware.org/ml/libc-alpha/2018-08/msg00190.html> applied,
makes Python 3.4 or later a required tool for building glibc, so
allowing changes of awk, perl etc. code used in the build and to
Python code without any such changes needing makefile conditionals or
to handle older Python versions. It needs substantive review of the
changes, as well as consensus on introducing such a Python requirement
which is under discussion in other threads.
This patch makes the configure test for Python check the version and
give an error if Python is missing or too old, and removes makefile
conditionals that are no longer needed. It does not itself convert
any code from another language to Python, and does not remove any
compatibility with older Python versions from existing scripts.
I have two places in mind for removing such compatibility:
conform/glibcconform.py could use tempfile.TemporaryDirectory, added
in Python 3.2, and scripts/build-many-glibcs.py would no longer need
compatibility for missing os.cpu_count or re.fullmatch, both added in
Python 3.4. Of course build-many-glibcs.py is not formally something
for which glibc's own build requirements apply - it already requires
Python 3 anyway - but clearly there's no use in it supporting versions
older than the minimum for building glibc, once glibc requires Python
3.4 or later to build.
If we get consensus on the Python requirement, I have the gen-as-const
machinery in mind as an early piece of build code to move to Python.
Tested for x86_64.
2018-10-12 Joseph Myers <joseph@codesourcery.com>
* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER. Set
critic_missing for versions before 3.4.
* configure: Regenerated.
* manual/install.texi (Tools for Compilation): Document
requirement for Python to build glibc.
* INSTALL: Regenerated.
* benchtests/Makefile [PYTHON]: Make code unconditional.
* conform/Makefile [PYTHON]: Likewise.
* manual/Makefile [PYTHON]: Likewise.
* math/Makefile [PYTHON]: Likewise.
diff --git a/INSTALL b/INSTALL
index 50bd113d55..3884ada8d8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -531,11 +531,11 @@ build the GNU C Library:
work with any version of 'sed'. As of release time, 'sed' version
4.5 is the newest verified to work to build the GNU C Library.
- * Python 2.7/3.4 or later
+ * Python 3.4 or later
- Python is required to build the GNU C Library manual and to run
- some tests. As of release time, Python 3.6 is the newest verified
- to work for testing the GNU C Library.
+ Python is required to build the GNU C Library. As of release time,
+ Python 3.6 is the newest verified to work for building and testing
+ the GNU C Library.
* PExpect 4.0
diff --git a/NEWS b/NEWS
index 270abc1905..3d13b321a7 100644
--- a/NEWS
+++ b/NEWS
@@ -48,7 +48,7 @@ Deprecated and removed features, and other changes affecting compatibility:
Changes to build and runtime requirements:
-* Python is required to build the GNU C Library manual.
+* Python 3.4 or later is required to build the GNU C Library.
Security related changes:
diff --git a/benchtests/Makefile b/benchtests/Makefile
index bcd6a9c26d..09da2f765f 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -174,14 +174,7 @@ $(error Invalid BENCHSET value)
endif
endif
-# Define the bench target only if the target has a usable python installation.
-ifdef PYTHON
bench: bench-build bench-set bench-func bench-malloc
-else
-bench:
- @echo "The bench target needs python to run."
- @exit 1
-endif
# Target to only build the benchmark without running it. We generate locales
# only if we're building natively.
diff --git a/configure b/configure
index f30c31afdc..535e2f62e0 100755
--- a/configure
+++ b/configure
@@ -5344,19 +5344,30 @@ fi
test -n "$PYTHON_PROG" && break
done
-test -n "$PYTHON_PROG" || PYTHON_PROG="no"
-case "x$PYTHON_PROG" in
-xno|x|x:) PYTHON_PROG=no ;;
-*) ;;
-esac
-
-if test "x$PYTHON_PROG" = xno; then
- aux_missing="$aux_missing python"
+if test -z "$PYTHON_PROG"; then
+ ac_verc_fail=yes
else
- PYTHON="$PYTHON_PROG -B"
+ # Found it, now check the version.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $PYTHON_PROG" >&5
+$as_echo_n "checking version of $PYTHON_PROG... " >&6; }
+ ac_prog_version=`$PYTHON_PROG --version 2>&1 | sed -n 's/^.*Python \([0-9][0-9.]*\).*$/\1/p'`
+ case $ac_prog_version in
+ '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
+ 3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*)
+ ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
+ *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
+$as_echo "$ac_prog_version" >&6; }
fi
+if test $ac_verc_fail = yes; then
+ critic_missing="$critic_missing python"
+fi
+
+PYTHON="$PYTHON_PROG -B"
+
test -n "$critic_missing" && as_fn_error $? "
*** These critical programs are missing or too old:$critic_missing
diff --git a/configure.ac b/configure.ac
index e983fd8faa..6cc10ede98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1050,18 +1050,12 @@ else
fi
# Check for python3 if available, or else python.
-AC_CHECK_PROGS(PYTHON_PROG, python3 python,no)
-case "x$PYTHON_PROG" in
-xno|x|x:) PYTHON_PROG=no ;;
-*) ;;
-esac
-
-if test "x$PYTHON_PROG" = xno; then
- aux_missing="$aux_missing python"
-else
- PYTHON="$PYTHON_PROG -B"
- AC_SUBST(PYTHON)
-fi
+AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
+ [Python \([0-9][0-9.]*\)],
+ [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
+ critic_missing="$critic_missing python")
+PYTHON="$PYTHON_PROG -B"
+AC_SUBST(PYTHON)
test -n "$critic_missing" && AC_MSG_ERROR([
*** These critical programs are missing or too old:$critic_missing
diff --git a/conform/Makefile b/conform/Makefile
index 71e58a46c8..a2bbe0fb24 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -120,9 +120,7 @@ linknamespace-symlists-base := $(foreach std,$(conformtest-standards),\
symlist-$(std))
linknamespace-symlists-tests := $(addprefix $(objpfx),\
$(linknamespace-symlists-base))
-ifdef PYTHON
tests-special += $(linknamespace-symlists-tests)
-endif
linknamespace-symlist-stdlibs-base := $(foreach std,$(conformtest-standards),\
symlist-stdlibs-$(std))
@@ -130,9 +128,7 @@ linknamespace-symlist-stdlibs-tests := \
$(addprefix $(objpfx),\
$(linknamespace-symlist-stdlibs-base))
-ifdef PYTHON
tests-special += $(linknamespace-symlist-stdlibs-tests)
-endif
linknamespace-header-base := $(foreach std,\
$(conformtest-standards),\
@@ -141,9 +137,7 @@ linknamespace-header-base := $(foreach std,\
$(std)/$(h)/linknamespace.out))
linknamespace-header-tests := $(addprefix $(objpfx),\
$(linknamespace-header-base))
-ifdef PYTHON
tests-special += $(linknamespace-header-tests)
-endif
include ../Rules
diff --git a/manual/Makefile b/manual/Makefile
index 9c35c9d45f..5f6006dc09 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -172,7 +172,7 @@ include ../Rules
install-data subdir_install: install
# Generated files requiring python: libm-err.texi
# Generated files requiring perl: summary.texi
-ifneq ($(if $(PYTHON),$(PERL),no),no)
+ifneq ($(PERL),no)
ifneq ($(strip $(MAKEINFO)),:)
install: $(inst_infodir)/libc.info
@if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
diff --git a/manual/install.texi b/manual/install.texi
index 08a39f57c9..c19002340b 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -575,11 +575,11 @@ with any version of @code{sed}. As of release time, @code{sed} version
4.5 is the newest verified to work to build @theglibc{}.
@item
-Python 2.7/3.4 or later
+Python 3.4 or later
-Python is required to build the @glibcadj{} manual and to run some
-tests. As of release time, Python 3.6 is the newest verified to work
-for testing @theglibc{}.
+Python is required to build @theglibc{}. As of release time, Python
+3.6 is the newest verified to work for building and testing
+@theglibc{}.
@item PExpect 4.0
diff --git a/math/Makefile b/math/Makefile
index 750492b381..34db0215ef 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -255,7 +255,6 @@ tests += test-math-isinff test-math-iszero test-math-issignaling \
test-math-iscanonical test-math-cxx11 test-math-iseqsig
endif
-ifdef PYTHON
libm-vec-tests = $(addprefix test-,$(libmvec-tests))
libm-test-support = $(foreach t,$(test-types),libm-test-support-$(t))
test-extras += $(libm-test-support)
@@ -351,9 +350,7 @@ $(libm-test-c-narrow-obj): $(objpfx)libm-test%.c: libm-test%.inc \
auto-libm-test-out%
$(make-target-directory)
$(PYTHON) gen-libm-test.py -c $< -a auto-libm-test-out$* -C $@
-endif
-ifdef PYTHON
tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp2 expm1 fdim floor \
fma fmax fmin fmod frexp hypot ilogb ldexp lgamma llrint \
llround log10 log1p log2 logb lrint lround nearbyint \
@@ -380,7 +377,6 @@ tests-special += $(objpfx)test-tgmath3-macro-list.out
$(objpfx)test-tgmath3-macro-list.out: gen-tgmath-tests.py
$(PYTHON) $< check-list $(tgmath3-macros) > $@; \
$(evaluate-test)
-endif
libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
libm-test-vec-cflags = $(libm-test-fast-math-cflags) -fno-inline \
@@ -476,7 +472,6 @@ $(objpfx)gen-libm-templates.stmp: Makefile
$(foreach t, $(call type-foreach, $(gen-all-calls)), \
$(objpfx)$(t).c): $(objpfx)gen-libm-templates.stmp
-ifdef PYTHON
# This must come after the inclusion of sysdeps Makefiles via Rules.
$(foreach t,$(libm-tests-normal),$(objpfx)$(t).c): $(objpfx)test-%.c:
@@ -637,11 +632,6 @@ regen-ulps: $(addprefix $(objpfx),$(libm-tests))
echo "Difference between the current baseline and the new baseline is:";\
diff -urN $(ulps-file) $(objpfx)NewUlps; \
echo "Copy $(objpfx)NewUlps to $(ulps-file) (relative to source)."
-else
-regen-ulps:
- @echo "Automatic regeneration of ULPs requires python."; \
- exit 1;
-endif
# The generated sysd-rules file defines rules like this for sources
# coming from sysdeps/ directories. These rules find the generic sources.
--
Joseph S. Myers
joseph@codesourcery.com