I tried to remove -fno-builtin and found that everything works fine, and when used with LTO, the performance of some use cases improves significantly due to string functions can be inlined. Is -fno-builtin still necessary in overlay mode?
Just to clarify: are you trying to compile libc as a bitcode archive, then statically LTO-link it in to your application?
Yes, I’ve found that this significantly improves performance for programs that heavily utilize string functions.
So, unfortunately, it isn’t actually sound to LTO-in the contents of a libc. This is something we’re actively working on fixing upstream.
The short version of the reason is that more or less, all linking is done by the time LTO starts. However, the LTO compiler can insert calls to new libc functions after linking finishes. If this were to bring in new bitcode, it would never have the opportunity to be compiled, and the link fails.
We do have ways to fix this, but they’re a work in progress. I’ll also note that this often does work; most of these kinds of transforms tend to happen before the link, during the initial compile. But that’s just a matter of chance, really.
Thanks, I see. My program is actually quite large (100MB), but when I did this, I didn’t encounter any linker failures, so I assumed it worked perfectly. My program also includes a lot of non-LTO code that references libc symbols, so I guess that’s why it happened to work.