-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
gh-96761: Fix lto-build for clang #96762
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
configure.ac
Outdated
@@ -1829,7 +1829,7 @@ if test "$Py_LTO" = 'true' ; then | |||
case $CC in | |||
*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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LDFLAGS_NOLTO
should be linker flags without LTO, hence the name no lto
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, at this moment -flto=${Py_LTO_POLICY}
could be -flto=default
so it's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see: #96762 (comment)
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 <[email protected]>
@matthiasgoergens cc @tiran A. Using ThinLTO as the default LTO policy for clang is not decided yet, #96766 will cover the issue. |
How do I put this to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
# 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.
Co-authored-by: Dong-hee Na <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 recognized
This patch fixes that problem.