From 4d43c13828a5910882eb91d5148d3d2493cda464 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 13 Feb 2025 09:08:46 -0600 Subject: [PATCH] Enable full LTO on Python 3.12 and 3.13 --- cpython-unix/build-cpython.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index 566700e0..8cb92d14 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -427,7 +427,11 @@ if [ -n "${CPYTHON_OPTIMIZED}" ]; then fi if [ -n "${CPYTHON_LTO}" ]; then - CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-lto" + # On Python 3.12 and 3.13, `--with-lto` enables ThinLTO by default, while on other versions it + # enables full LTO. We prefer runtime performance over build time, so force full on all + # versions. + # See https://docs.python.org/3.14/using/configure.html#cmdoption-with-lto + CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-lto=full" fi # Python 3.11 introduces a --with-build-python to denote the host Python.