From 39f408f66a2e73545e732eaf310f37624e6561fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Wed, 21 Jan 2026 17:10:46 +0100 Subject: [PATCH] Allow overriding COMPILER with UNVERSIONED_COMPILER Introduce UNVERSIONED_COMPILER variable in Makefile.pre.in to allow overriding the COMPILER macro definition during the build of Python/getcompiler.o. This enables reproducible builds by providing a way to set a generic compiler identification string (e.g., "[GCC]") instead of the default versioned one. The rule is made conditional on UNVERSIONED_COMPILER being defined. References: https://discuss.python.org/t/unversioned-compiler-symbol-for-getcompiler-c/91735 Fixes: https://github.com/python/cpython/issues/144121 --- Makefile.pre.in | 7 +++++++ .../Build/2026-01-21-19-28-11.gh-issue-144121.gaqpK-.rst | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2026-01-21-19-28-11.gh-issue-144121.gaqpK-.rst diff --git a/Makefile.pre.in b/Makefile.pre.in index 8531162943ae35..bf01f7ff4f835c 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1926,6 +1926,13 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \ -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \ -o $@ $(srcdir)/Modules/getbuildinfo.c +ifdef UNVERSIONED_COMPILER +Python/getcompiler.o: $(srcdir)/Python/getcompiler.c Makefile + $(CC) -c $(PY_CORE_CFLAGS) \ + -DCOMPILER='"$(UNVERSIONED_COMPILER)"' \ + -o $@ $(srcdir)/Python/getcompiler.c +endif + Modules/getpath.o: $(srcdir)/Modules/getpath.c Python/frozen_modules/getpath.h Makefile $(PYTHON_HEADERS) $(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ -DPREFIX='"$(host_prefix)"' \ diff --git a/Misc/NEWS.d/next/Build/2026-01-21-19-28-11.gh-issue-144121.gaqpK-.rst b/Misc/NEWS.d/next/Build/2026-01-21-19-28-11.gh-issue-144121.gaqpK-.rst new file mode 100644 index 00000000000000..d830d100b75d27 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-01-21-19-28-11.gh-issue-144121.gaqpK-.rst @@ -0,0 +1,2 @@ +Make it possible for the COMPILER definition in getcompiler.c to be static +in order to make builds reproducible.