<div>-  // If we don't preserve any symbols, libLTO will assume that all symbols are</div><div>-  // needed. Keep all symbols unless we're producing a final executable.</div><div><br></div><div>Please keep the first sentence of that comment, it's still pertinent. We handle that case by calling lto_codegen_dispose later.</div>

<div><br></div><div>This patch is obviously correct given the changes in gold upstream, please commit!</div><div><br></div><div>Nick</div><br><div class="gmail_quote">On 2 June 2010 18:50, Rafael Espindola <span dir="ltr"><<a href="mailto:espindola@google.com">espindola@google.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">With the attached patch the plugin will no longer preserve all symbols<br>
in a .so and instead will trust gold to know what is needed. The<br>
result is that it is now able to drop unnecessary symbol from shared<br>
libraries. An example adapted from<br>
<a href="http://llvm.org/releases/2.6/docs/LinkTimeOptimization.html" target="_blank">http://llvm.org/releases/2.6/docs/LinkTimeOptimization.html</a>:<br>
<br>
$ clang -c a.c -emit-llvm -fdata-sections -ffunction-sections -fPIC<br>
$ clang -c main.c -fdata-sections -ffunction-sections -fPIC<br>
$ ld --no-add-needed --eh-frame-hdr --build-id -m elf_x86_64<br>
--hash-style=gnu -shared -o foo.so<br>
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crti.o<br>
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/crtbeginS.o<br>
-L/usr/lib/gcc/x86_64-redhat-linux/4.4.4<br>
-L/usr/lib/gcc/x86_64-redhat-linux/4.4.4<br>
-L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64<br>
-L/lib/../lib64 -L/usr/lib/../lib64<br>
-L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../.. main.o a.o -lgcc<br>
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s<br>
--no-as-needed /usr/lib/gcc/x86_64-redhat-linux/4.4.4/crtendS.o<br>
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crtn.o<br>
-plugin=/home/espindola/llvm/build/Debug/lib/LLVMgold.so<br>
--gc-sections -plugin-opt=generate-api-file<br>
$ cat apifile.txt<br>
foo1<br>
foo5<br>
$ objdump  -d foo.so | grep foo4<br>
<br>
Gold itself is still not as aggressive as it could be, but that is<br>
another patch :-)<br>
<br>
And yes, I do have to implement support for gold plugin's in clang!<br>
<br>
Cheers,<br>
<font color="#888888">--<br>
Rafael Ávila de Espíndola<br>
</font></blockquote></div><br>