-
Notifications
You must be signed in to change notification settings - Fork 96
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
Strip utility does not have LTO support, mangles archives #49
Comments
Introduce STRIP_MASK functionality to work around STRIP LTO plugin bug (workaround #49)
looks like there is now an llvm-strip tool, might be an interesting platform if development work is required https://www.phoronix.com/scan.php?page=news_item&px=LLVM-Strip |
Been looking into this again, and it looks like strip works fine on LTO object files as long as they aren't in a static archive. Putting them in a static archive mangles the archive. It's definitely the index. I do have a rudimentary patch to Portage that invokes ranlib as a workaround, but I'm unwilling to commit to it just yet. |
I tried llvm-strip, too, but it doesn't support a number of GNU strip options which causes other problems. It also doesn't appear to handle static archives. However, I'd be willing to switch to it if it addresses these problems eventually. One more thing:
|
AFAIK |
Based on the binutils sources I think you're right. I found this relevant snippet in
It's not easy to read, and I'm not even sure if this is the offending code just yet, but if I understand correctly it is applying the same logic to non-LTO symbols as it does to LTO symbols, hence the warning. This code appears to be what generates the archive index/header. If I had to guess, this is where the header gets mangled. |
Okay, after more poking around, it does appear to be directly relevant. It is indeed the index generation code. The problem is it doesn't understand how to build an index for LTO symbols. Curiously, ranlib does. |
Need some review: workaround patch in interim for Portage.
|
Patch portage to rebuild static archive indexes to fix mangled LTO symbols. Address issue #49, Fix #119 Signed-off-by: Shane Peelar <[email protected]>
Could you apply the patch to sys-apps/portage-mgorny too, please? |
I can see no reason why not! However, I cannot test as I don't use that version of portage. Could you try it yourself and verify it works as described in |
What do I need to test exactly? |
Apply the patch to |
I think, actually, I could implement this functionality in |
LTO patches are now applied directly from lto-overlay, using functionality replicated directly from portage. /etc/patches is now left untouched by LTOize, and a script, 41-lto-patch.sh, is symlinked into your portage bashrc.d. You can experiment with your own LTO patches in /etc/patches as usual. Please consider submitting them upstream if you make working ones. Also, with this change, we no longer need to increment the version number with LTOize whenever new patches come in. Address #49 Signed-off-by: Shane Peelar <[email protected]>
OK, so investigating further, it looks like it makes more sense to have this functionality in portage for now instead of in |
Thank you! I did not manage to understand how all this stuff works and how to verify it. |
No worries. @mgorny accepted the patch upstream, so you should get it soon. It may be accepted into upstream Portage as well thanks to this. |
Is this related to the script installed by portage-bashrc-mv? |
Well, it's a patch that's installed via an installed |
There we go, essentially exact same as the patch here minus the lto overlay message.
|
Beautiful. Unless there are any objections, I think we can finally close this issue for good! |
I just noticed some builds spitting out a bunch of aforementioned
EDIT2: Uh, taking the first edit back, for some reason exactly one build of binutils passed without any |
The warnings will still be thrown up (can't be avoided), but a message should be printed after to inform you that the archive in question had its index rebuilt. In other words, strip mangles it, and then ranlib is run to fix it. |
This is a bit of a long running issue that unfortunately needs upstream support in order to fix. I'll detail it here for interested parties.
Upstream Gentoo bug: https://bugs.gentoo.org/603594
Upstream binutils bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21479
The
strip
utility in LTO builds will commonly emit errors like this for static archives:Originally I didn't think this was a problem since that should effectively make it a no-op. I was wrong, though -- it actually makes the static archive unusable (I believe this has something to do with the index).
The real solution to this will be introducing LTO support into
strip
. However, a workaround is needed in the meantime. The linked upstream threads suggest a few optionsranlib
afterstrip
(requires a Portage patch, but it does seem to fix it... I'm unsure of the effects of this on non-LTO systems)-ffat-lto-objects
or remove-flto
(Obviously not ideal)@pchome has suggested a workaround that we'll be using in the meantime, which is to set the
STRIP_MASK
variable to disable stripping static archives only (stripping binaries still). This is the best workaround right now until the upstream issues are sorted out. We can close this issue when things are handled properly upstream.The text was updated successfully, but these errors were encountered: