This is a bit of experiment that I wanted to carry out for a long time and now finally got a chance to do. It's basically about enabling LTO on all major bits in stand and see if it helps to bring the bloat down. And it turned out surprisingly easy to pull off and very fruitful. Below is the summary table of the results.
{F81677572, width=600}
The change consists of the following:
1. Enabling LTO on all bits and pieces (i.e. build intermediary static libs as IR code).
2. Using symbol versioning tables to demote all but one symbol to locals.
3. Fixing (more like a workarounding) a fallout of symbol being present multiple times in ZFS code. Has a lot to do with the hackish way ZFS is composed by including ".c" file into another ".c".
4. Fixing unrelated bug in efi/boot1/Makefile that would pull file already provide by the libsa that is being linked in.
5. Fix to pre-existing issue which is that EFI code needs to use -fshort-wchar (by the EFI book), and has the appropriate flag set. At the same time it links to the libsa, which has default wchar size of 32 bits on aarch64 and amd64. That makes lld unhappy. Such issue was easily missed before since such information won't survive the lowering to native code. I don't think anything else uses wchars in the code, so I opted to just enable it for everything.
The patch is against releng/13.2 (this is what I had on my machine)As it can be seen, mainly for discussion at this pointthe gain is quite substantial esp for the EFI parts. If the input is positive,Not so much because of LTO but simply because there seems to be quite a lot of garbage being linked in right now. I'll bring it up to the latest master.
As it can be seen,The only significant loss is 40 bytes off boot2, but we are still within a safe margin. the gain is quite substantial esp for the EFI parts.If you are look at the table holistically, Not so much because of LTO but simply because there seems to be quite a lot of garbage being linked in right now.the new size "hierarchy" makes much more sense, The only significant loss is 40 bytes off boot2since EFI component is not more than 100K in size, but we are still within a safe marginso there is no real reason for the EFI versions of the loader being 2x in size.