FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-96761: Fix lto-build for clang by matthiasgoergens · Pull Request #96762 · python/cpython · GitHub

Repository navigation

gh-96761: Fix lto-build for clang - #96762

Closed
matthiasgoergens wants to merge 5 commits into
python:mainfrom
matthiasgoergens:matthias/fix-lto-for-clang
Closed

matthiasgoergens wants to merge 5 commits into
python:mainfrom
matthiasgoergens:matthias/fix-lto-for-clang

Conversation

matthiasgoergens commented Sep 12, 2022 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please re-generate configure file by using the following command.

docker run --rm --pull=always -v$(pwd):/src quay.io/tiran/cpython_autoconf:269

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

corona10 requested a review from tiran September 12, 2022 08:17
Comment thread configure.ac Outdated
*clang*)
dnl flag to disable lto during linking
LDFLAGS_NOLTO="-fno-lto"
LDFLAGS_NOLTO="-flto=${Py_LTO_POLICY}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LDFLAGS_NOLTO should be linker flags without LTO, hence the name no lto.

matthiasgoergens Sep 12, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I updated the comment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Does thin LTO linking work with object files that are built with full LTO? This would speed up LTO builds a bit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

IIUC, at this moment -flto=${Py_LTO_POLICY} could be -flto=default so it's wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, let me think about how to fix this. Or do you have a suggestion?

Copy link
Copy Markdown
Contributor Author

Please re-generate configure file by using the following command.

docker run --rm --pull=always -v$(pwd):/src quay.io/tiran/cpython_autoconf:269

Done!

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

Copy link
Copy Markdown

Thanks for making the requested changes!

@corona10: please review the changes made to this pull request.

corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copy link
Copy Markdown

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Comment thread configure.ac Outdated
Co-authored-by: Christian Heimes <christian@python.org>

Copy link
Copy Markdown
Contributor Author

@corona10 Just to be sure: does your PR at #96766 obsolete this one?

If yes, I'll close mine.

corona10 commented Sep 14, 2022 •
edited
Loading

Copy link
Copy Markdown
Member

@matthiasgoergens cc @tiran
There are several consensuses on this issue.

A. Using ThinLTO as the default LTO policy for clang is not decided yet, #96766 will cover the issue.
B. If #96766 is merged we can use ThinLTO on clang for bootstrap_python if needed.
C. But A and B do not mean that bootstrap_python should be built with clang by using LTO. (If needed we should use it, but if it is not a root cause we don't need to use it) since I can not meet the same issue on macOS with clang so I need to reproduce the issue on Linux first. I need to know the root cause.

Copy link
Copy Markdown
Member

@corona10 Just to be sure: does your PR at #96766 obsolete this one?

So in conclusion, it's a slightly different issue.

Comment thread configure.ac Outdated

corona10 left a comment •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@matthiasgoergens

  • Please rebase the PR and regen configure with the suggested changes.
  • Please update the following comment also (for clang case).

    cpython/Makefile.pre.in

    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 <donghee.na92@gmail.com>

corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would you like to regenerate the configure by using docker run --rm --pull=always -v$(pwd):/src quay.io/tiran/cpython_autoconf:269?

Copy link
Copy Markdown
Contributor Author

Closed in favour of #96945

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL