[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.

Daniel Dunbar daniel at zuster.org
Sun Jul 12 13:50:22 PDT 2009


That's pretty awesome!

Will ar, etc. eventually get some autodiscovery of plugins so that
things work OOTB after a make install of llvm/llvm-gcc?

 - Daniel

On Tue, May 26, 2009 at 10:52 AM, Rafael Espindola<espindola at google.com> wrote:
> For some time now the gold linker has support for plugins and llvm has
> a plugin for it.
>
> Unfortunately, it was still not possible to do fully transparent LTO
> on linux because ar had no support for plugins and a library created
> with llvm files in it would have no symbol table and would be rejected
> by gold.
>
> Today support for plugins has been committed to BFD. That is the file
> format abstraction library used by binutils. This now works
>
> $ llvm-gcc -emit-llvm -O2 -c a.c
> $ llvm-gcc -emit-llvm -O2 -c b.c
> $ ar --plugin libLLVMgold.so q a.a a.o
> $ llvm-gcc -use-gold-plugin b.o a.a -o t
> $ objdump  -d t  | grep main\>: -A 2
> 0000000000400330 <main>:
>  400330:       31 c0                   xor    %eax,%eax
>  400332:       c3                      retq
>
> with a.c being "int f(void) {  return 0;}" and b.c being "int f(void);
> int main(void) { return f(); }".
>
> BFD will also search for plugins in <prefix>/lib/bfd-plugins. You can
> just put libLLVMgold.so there and all you will need for LTO is to pass
> -use-gold-plugin while linking :-)
>
> Note that you must use the gold linker for -use-gold-plugin to work :-)
>
> Cheers,
> --
> Rafael Avila de Espindola
>
> Google | Gordon House | Barrow Street | Dublin 4 | Ireland
> Registered in Dublin, Ireland | Registration Number: 368047
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list