gh-96761: Fix lto-build for clang#96762
Conversation
When enabling link time optimization for clang, you eventually get the following error: `Modules/getbuildinfo.o: file not recognized: file format not recognized` This patch fixes that problem.
corona10
left a comment
There was a problem hiding this comment.
Please re-generate configure file by using the following command.
docker run --rm --pull=always -v$(pwd):/src quay.io/tiran/cpython_autoconf:269
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
| *clang*) | ||
| dnl flag to disable lto during linking | ||
| LDFLAGS_NOLTO="-fno-lto" | ||
| LDFLAGS_NOLTO="-flto=${Py_LTO_POLICY}" |
There was a problem hiding this comment.
LDFLAGS_NOLTO should be linker flags without LTO, hence the name no lto.
There was a problem hiding this comment.
I guess I'll need to make a bigger change, that changes the name to something more descriptive.
# LDFLAGS_NOLTO is an extra flag to disable lto. It is used to speed up building
# of _bootstrap_python and _freeze_module tools, which don't need LTO.
For clang that seems to work better when they are the same as for the rest of the build. The thin-lto build is already plenty fast (and even then, a slow build is better than a broken one).
There was a problem hiding this comment.
clang does not support linking with objects that have LTO information? It works fine for GCC. Could you please update the comment on line 1831?
There was a problem hiding this comment.
I am not quite sure what the exact rootcause is. I just noticed that when I tried to build some things with LTO and some things (like _bootstrap_python) without LTO, I get an error from the linker via clang.
There was a problem hiding this comment.
I updated the comment.
There was a problem hiding this comment.
Does thin LTO linking work with object files that are built with full LTO? This would speed up LTO builds a bit.
There was a problem hiding this comment.
IIUC, at this moment -flto=${Py_LTO_POLICY} could be -flto=default so it's wrong.
There was a problem hiding this comment.
Hmm, let me think about how to fix this. Or do you have a suggestion?
Done! |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @corona10: please review the changes made to this pull request. |
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Co-authored-by: Christian Heimes <christian@python.org>
|
@matthiasgoergens cc @tiran A. Using ThinLTO as the default LTO policy for clang is not decided yet, #96766 will cover the issue. |
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
- Please rebase the PR and regen configure with the suggested changes.
- Please update the following comment also (for clang case).
Lines 94 to 95 in 1fc8bd3
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
corona10
left a comment
There was a problem hiding this comment.
Would you like to regenerate the configure by using docker run --rm --pull=always -v$(pwd):/src quay.io/tiran/cpython_autoconf:269?
|
Closed in favour of #96945 |
When enabling link time optimization for clang, you eventually get the following error:
Modules/getbuildinfo.o: file not recognized: file format not recognizedThis patch fixes that problem.