This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ./configure --enable-optimizations should enable LTO
Type: Stage:
Components: Build Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: corona10, erlendaasland, gregory.p.smith, methane, ned.deily, pablogsal, vstinner
Priority: normal Keywords:

Created on 2021-10-05 09:32 by vstinner, last changed 2022-04-11 14:59 by admin.

Messages (9)
msg403209 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-05 09:32
When Python is configured with:

   ./configure --enable-optimizations

PGO is enabled but not LTO.

I recall that a few years ago, GCC with LTO had bugs. But now, GCC with LTO is reliable. I suggest to enable it by default in Python 3.11.

Or did I miss a reason to not do that?
msg403210 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-05 09:34
IIRC activating lto is specially annoying on MacOS due to the need of some llvm components that are a bit hard to get. Let me dig a bit to see if I reproduce the problem
msg403211 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-10-05 09:38
Pablo:
> IIRC activating lto is specially annoying on MacOS due to the need of some llvm components that are a bit hard to get. Let me dig a bit to see if I reproduce the problem

Ah, I guess that you are referring to this requirement:
"The C compiler Clang requires llvm-ar for LTO (ar on macOS), as well as an LTO-aware linker (ld.gold or lld)."
https://docs.python.org/dev/using/configure.html#cmdoption-with-lto

Maybe configure can enable LTO on all platforms but macOS.
msg403244 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-10-05 15:49
> IIRC activating lto is specially annoying on MacOS due to the need of some llvm components that are a bit hard to get

Can you say more? We are currently using --with-lto with a vanilla Apple Command Line Tools (or Xcode) for macOS installer builds when building on macOS 10.15 High Sierra or higher.  Perhaps this was just an issue on older versions.
msg403248 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-05 16:12
Yeah, I had problems in the past to get llvm-ar or some other component. I still need time to reproduce and to see if this still happens on new versions.
msg403249 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-10-05 16:15
I don't think you need llvm-ar anymore with the Apple Tool Chain but let me look into it as I have all the relevant previous macOS releases as VMs to test with.
msg414312 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2022-03-01 22:29
FWIW I agree that we should try adding LTO to --enable-optimizations now.
msg414313 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-03-01 22:34
Sorry, this slipped off my radar and I haven't gone back and checked older versions of macOS. But it certainly is true that at least with the current versions of the Apple Developer Tools (either the Command Line Tools or Xcode) for macOS 11 (Big Sur) and macOS 12 (Monterey), things just work.
msg414316 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2022-03-01 22:56
Can we use --lto=thin when availabe?
And can we not use --lto when building profiling python?
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89536
2022-03-03 09:51:27erlendaaslandsetnosy: + erlendaasland
2022-03-01 22:56:10methanesetnosy: + methane
messages: + msg414316
2022-03-01 22:34:08ned.deilysetmessages: + msg414313
2022-03-01 22:29:57gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg414312
2021-10-11 14:32:35corona10setnosy: + corona10
2021-10-05 16:15:00ned.deilysetmessages: + msg403249
2021-10-05 16:12:11pablogsalsetmessages: + msg403248
2021-10-05 15:49:28ned.deilysetnosy: + ned.deily
messages: + msg403244
2021-10-05 09:38:32vstinnersetmessages: + msg403211
2021-10-05 09:34:55pablogsalsetnosy: + pablogsal
messages: + msg403210
2021-10-05 09:32:25vstinnercreate