Skip to content
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

An idea for Portage to track LTO natively #17

Open
InBetweenNames opened this issue Sep 19, 2017 · 7 comments
Open

An idea for Portage to track LTO natively #17

InBetweenNames opened this issue Sep 19, 2017 · 7 comments

Comments

@InBetweenNames
Copy link
Owner

It seems to me it would be very nice to track which packages are LTOed with Portage natively, similar to how multilib works. For example, we could have a USE_EXPAND variable called LTO which could be set to nolto, lto, or both at once.

LTO="lto" would mean that the package is built with slim LTO objects (the default in our configuration)
LTO="nolto" would mean that the package is built without LTO at all (nolto.conf).
LTO="lto nolto" would mean that the package is built with fat LTO objects (ltofat.conf).

A package which is built with exclusively nolto must link against other libraries with nolto set (either exclusively or inclusively with nolto or lto nolto respectively).

A package which is built lto may link against nolto or lto libraries. But if any library is lto nolto then a rebuild is triggered if the status of it changes, to force the linker to choose the right symbols.

I'm not sure how much work this would actually be, but it would be nice to have something like this to integrate LTO into Portage natively. Furthermore it would open the door to using other compilers as well, such as clang, to build your system. I'm a GCC guy myself, but I think the option should be there for users. If anyone has any thoughts or suggestions on this, please comment!

@darkbasic
Copy link
Contributor

That would be really interesting, but sounds like a lot of work.

@InBetweenNames
Copy link
Owner Author

Indeed it does. I can't think of any other way to do this than to patch Portage itself. That said, I think a lot of existing infrastructure could be re-used. The hardest part would probably be learning Portage's internals. I do know there are extension mechanisms in there at least.

@darkbasic
Copy link
Contributor

I'm pretty sure you can reuse lots of things, but from what I heard learning portage internals is far from being easy. Good luck, you have my fingers crossed :)

@InBetweenNames
Copy link
Owner Author

Fortunately for us, we have no deadlines :)

@InBetweenNames
Copy link
Owner Author

Alright, after seeing a few things I'm noticing a pattern. We could create a bashrc.d script for all GentooLTO related business, like LTO patches (instead of using /etc/patches) (#105), tracking which packages are compiled with LTO enabled (for dependency tracking), AutoFDO injection (#150), fixing mangled archives (#49), and -fwhole-program injection for packages that can be built as a unity build with meson (#151).

This would concisely solve these existing problems in a pluggable way, with functionality that could be enabled or disabled via USE flags on sys-config/ltoize.

Honestly, I can't believe I hadn't thought of this sooner. This is the whole point of bashrc.d after all :)

For this issue, it should also be possible for an ebuild to specify an LTO override directly where the *FLAGS themselves are not modified, and the ebuild itself ensures that the package is built with LTO in its own way (an LTO_CUSTOM variable, for example). For users who build their kernels with LTO, this could be particularly useful, and be trackable via portage.

I'm not sure if a USE_EXPAND variable will make sense for this, though. It will probably have to be grafted in manually as a "pseudo USE-flag", or something like that.

@ghost
Copy link

ghost commented Apr 18, 2019

Hi. Does this mean that if A uses library B and B uses C (all three are lto), then upgrading C will automatically trigger subsequent rebuild of B and of A?

@InBetweenNames
Copy link
Owner Author

InBetweenNames commented Apr 25, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants