Rafael Espindola
2009-May-26 17:52 UTC
[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
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
Chris Lattner
2009-Jul-07 18:46 UTC
[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
On May 26, 2009, at 10:52 AM, Rafael Espindola wrote:> Today support for plugins has been committed to BFD. That is the file > format abstraction library used by binutils. This now worksVery nice Rafael! Can you please update the web page to mention this, e.g. in the LinkTimeOptimization.html document and wherever else relevant? -Chris> > $ 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
Rafael Espindola
2009-Jul-08 11:14 UTC
[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
2009/7/7 Chris Lattner <clattner at apple.com>:> > On May 26, 2009, at 10:52 AM, Rafael Espindola wrote: >> >> Today support for plugins has been committed to BFD. That is the file >> format abstraction library used by binutils. This now works > > Very nice Rafael! Can you please update the web page to mention this, e.g. > in the LinkTimeOptimization.html document and wherever else relevant?It was already documented in http://llvm.org/docs/GoldPlugin.html. I just changed the example a bit to show that ar works.> -Chris >Cheers, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047
Daniel Dunbar
2009-Jul-12 20:50 UTC
[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
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 >
Rafael Espindola
2009-Jul-13 08:38 UTC
[LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
2009/7/12 Daniel Dunbar <daniel at zuster.org>:> That's pretty awesome!Thanks!> Will ar, etc. eventually get some autodiscovery of plugins so that > things work OOTB after a make install of llvm/llvm-gcc?The bfd library (used by ar and nm) already searches for plugins in $install_dir/lib/bfd-plugins/. Maybe we could pass an option to llvm's configure to tell it where to install a copy of the plugin?> - Daniel >Cheers, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047
Maybe Matching Threads
- [LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
- [LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
- [LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
- [LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.
- [LLVMdev] CVS binutils includes support for plugins, can use the llvm plugin.