Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable full LTO on Python 3.12 and 3.13 #529

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about 3.14? Did it change in 3.14?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.14a5 and below still defaults to ThinLTO. 3.14a6 (upcoming) will default back to fullLTO.

It's safe to just pass --with-lto=full to all versions of 3.14. That will always work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the linked documentation says they're reverting the ThinLTO default in 3.14.

Seems best to just set it on all versions.

# 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.
Expand Down