Issue 45373: ./configure --enable-optimizations should enable LTO (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/89536

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:50 admin set github: 89536
2022-03-03 09:51:27 erlendaasland set nosy: + erlendaasland
2022-03-01 22:56:10 methane set nosy: + methanemessages: +
2022-03-01 22:34:08 ned.deily set messages: +
2022-03-01 22:29:57 gregory.p.smith set nosy: + gregory.p.smithmessages: +
2021-10-11 14:32:35 corona10 set nosy: + corona10
2021-10-05 16:15:00 ned.deily set messages: +
2021-10-05 16:12:11 pablogsal set messages: +
2021-10-05 15:49:28 ned.deily set nosy: + ned.deilymessages: +
2021-10-05 09:38:32 vstinner set messages: +
2021-10-05 09:34:55 pablogsal set nosy: + pablogsalmessages: +
2021-10-05 09:32:25 vstinner create