Skip to content

Commit dab5e65

Browse files
[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 a497a11) Co-authored-by: Vismay <vismay.t@gmail.com>
1 parent 055e6b2 commit dab5e65

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎Makefile.pre.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE
127127
# LDFLAGS used to build executables and shared targets.
128128
PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST)
129129
CONFIGURE_EXE_LDFLAGS=@EXE_LDFLAGS@
130-
PY_CORE_EXE_LDFLAGS:= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
130+
PY_CORE_EXE_LDFLAGS= $(if $(CONFIGURE_EXE_LDFLAGS), $(CONFIGURE_EXE_LDFLAGS) $(PY_LDFLAGS_NODIST), $(PY_CORE_LDFLAGS))
131131
# Strict or non-strict aliasing flags used to compile dtoa.c, see above
132132
CFLAGS_ALIASING=@CFLAGS_ALIASING@
133133
# Compilation flags only for ceval.c.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix incorrect executable linking on macOS with ``--with-lto`` caused by
2+
premature expansion of Make's ``$@`` target variable.

0 commit comments

Comments
 (0)