<div dir="ltr">Hi Damjan,<div><br></div><div>Try building with function/data sections and linker gc enabled. I.e. "-ffunction-sections -fdata-sections -Wl,--gc-sections". If that doesn't help, then please post a test case.</div><div><br></div><div>If those hidden symbols were only referenced within the same translation unit aka module, then there shouldn't be a difference between full and thin LTO (the linker will tell the post-link compilation in both cases that there are no references outside the module and it could then be internalized and removed as long as all references in the module were inlined.</div><div><br></div><div>Assuming there are cross-module references initially:</div><div><br></div><div>With full LTO all objects are compiled post link in a monolithic blob, which means that if all references to a hidden symbol are inlined, it knows that there can be no additional references and the symbol can be removed.</div><div><br></div><div>With ThinLTO, each object is still compiled post link independently, while ThinLTO enables cross-module importing and inlining the defining module does not know whether those inlines were successful and therefore whether any cross-module references remain, so it needs to leave the outlined definition in place. If you enable function sections and linker GC, then the linker, when it links together the final native objects produced by the ThinLTO post-link compilations into the final native .so, can remove the symbols that were fully inlined across modules and no longer have any references.</div><div><br></div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 19, 2020 at 6:49 AM Damjan Marion via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi,<br>
<br>
I noticed that only when I use -flto=full functions which have hidden visibility are removed<br>
from code when I link it into .so file.<br>
<br>
Is this expected behaviour? Is there a way to achieve same with —flto=thin?<br>
<br>
Thanks<br>
<br>
— <br>
Damjan<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>