https://github.com/python/cpython/commit/dab5e65edc350377a774d56abed4e4adf65bfa78
commit: dab5e65edc350377a774d56abed4e4adf65bfa78
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: itamaro <[email protected]>
date: 2026-11-08T06:10:39Z
summary:

[3.15] gh-153285: Preserve LTO target names on macOS (GH-153532) (#161599)

gh-153285: Preserve LTO target names on macOS (GH-153532)

With `--with-lto` on macOS, linker flags include Make's `$@` target variable.
Immediate expansion in `PY_CORE_EXE_LDFLAGS` erased the target name,
causing executable links to share an LTO object path. Parallel links
could then produce incorrect executables and cause `test_embed` failures.

Use recursive assignment (`=` instead of `:=`) so `$@` expands when each
link recipe runs.
(cherry picked from commit a497a11c46c2bf096dd544e7a422cc457e806916)

Co-authored-by: Vismay <[email protected]>

files:
A Misc/NEWS.d/next/Build/2026-07-11-01-53-58.gh-issue-153285.YmSox4.rst
M Makefile.pre.in

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 55838444bb125df..b5d31640ec02231 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -127,7 +127,7 @@ PY_CORE_CFLAGS=     $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
 # LDFLAGS used to build executables and shared targets.
 PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
 CONFIGURE_EXE_LDFLAGS=@EXE_LDFLAGS@
-PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) 
$(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
+PY_CORE_EXE_LDFLAGS= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) 
$(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
 # Strict or non-strict aliasing flags used to compile dtoa.c, see above
 CFLAGS_ALIASING=@CFLAGS_ALIASING@
 # Compilation flags only for ceval.c.
diff --git 
a/Misc/NEWS.d/next/Build/2026-07-11-01-53-58.gh-issue-153285.YmSox4.rst 
b/Misc/NEWS.d/next/Build/2026-07-11-01-53-58.gh-issue-153285.YmSox4.rst
new file mode 100644
index 000000000000000..d672c8b9910d76d
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-07-11-01-53-58.gh-issue-153285.YmSox4.rst
@@ -0,0 +1,2 @@
+Fix incorrect executable linking on macOS with ``--with-lto`` caused by
+premature expansion of Make's ``$@`` target variable.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to