python / python/cpython

Make COMPILER definition in getcompiler.c optionally static for reproducible builds

Open
#144,121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

SUSE (both for SLE and openSUSE) have been using for a long time (the name of the patchfile starts with python-3.3.0b1 ;)) similar patch to avoid having dynamically generated symbols in the build binaries (version of compilers in this case).

---
 Makefile.pre.in |    5 +++++
 1 file changed, 5 insertions(+)

Index: Python-3.15.0a3/Makefile.pre.in
===================================================================
--- Python-3.15.0a3.orig/Makefile.pre.in	2025-12-19 02:26:23.594002103 +0100
+++ Python-3.15.0a3/Makefile.pre.in	2025-12-19 02:26:28.185444105 +0100
@@ -1926,6 +1926,11 @@
 	      -DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \
 	      -o $@ $(srcdir)/Modules/getbuildinfo.c
 
+Python/getcompiler.o: $(srcdir)/Python/getcompiler.c Makefile
+	$(CC) -c $(PY_CORE_CFLAGS) \
+		-DCOMPILER='"[GCC]"' \
+		-o $@ $(srcdir)/Python/getcompiler.c
+
 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)"' \

I have discussed upstreaming of this patch on
https://discuss.python.org/t/unversioned-compiler-symbol-for-getcompiler-c/91735 and it seems to me that in order to give this issue some momentum, I have to just file PR here.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-144124

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Python/getcompiler.c and its build rules in Makefile.pre.in, then review the linked work in gh-144124. Confirm how the COMPILER definition is built and make its static form optional without introducing dynamically generated compiler symbols; verify the build remains reproducible.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.