Rafael, Rui, This is obviously an old thread, but in case there is interest, I've been able to get this to work (using the LLVM gold plugin with the ld.bfd linker). This requires some additional logic in the ld.bfd linker (and a small change to the bfd library). I've attached the patch (against binutils HEAD from 2013-09-17) in case anyone finds this useful. The core issue is that ld.bfd is currently setup to use the GCC LTO plugin, which produces its IR in an ELF container, and we don't. As a result, ld.bfd needs to ask the plugin if it would like to claim files of unknown format (in addition to querying for recognized object files). -Hal P.S. For the record, I'm certainly not a binutils expert, this just seems to work for me. ----- Original Message -----> On 1 August 2012 23:00, Sun, Rui <rui.sun at intel.com> wrote: > > Hi, > > > > > > > > I am trying to use LLVM LTO. I read > > http://llvm.org/docs/GoldPlugin.html and > > have some questions. Could anyone help? > > > > > > > > 1. Can LLVMgold.so work with BFD LD instead of gold? In the > > description of changes in binutils 2.20, “* The plugin target has > > been added > > to bfd. It can load the same shared objects > > > > used by gold and uses them to provide basic support for new file > > formats.”. > > Does this mean BFD LD after 2.20 can support LLVMgold.so? Ld > > version on my > > system is: > > > > GNU ld (GNU Binutils for Ubuntu) 2.21.53.20110810 > > > > In theory it can, but I think it is completely untested. I think > that, as with gold, you have to build it with --enable-plugins. > > > > > 2. Gold only supports ELF. If BFD LD can support LLVMgold, > > can LTO be > > applied to COFF objects after recompiling the binutils with > > target==x86_64-pc-pe? > > Double untested, but I guess it could be made to work :-) > > > > > Thanks! > > > > Rui > > > > > > Cheers, > Rafael > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory -------------- next part -------------- A non-text attachment was scrubbed... Name: ldbfd-bin-plugin.patch Type: text/x-patch Size: 2121 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131010/fc3217b5/attachment.bin>
Quick update: the previous patch only worked for static linking; this version should work for both static and dynamic linking. I'm not going to send any more updated patches to this list, but please feel free to e-mail me off-list, and I'll be happy to share any updates I have at any point in the future. -Hal ----- Original Message -----> Rafael, Rui, > > This is obviously an old thread, but in case there is interest, I've > been able to get this to work (using the LLVM gold plugin with the > ld.bfd linker). This requires some additional logic in the ld.bfd > linker (and a small change to the bfd library). I've attached the > patch (against binutils HEAD from 2013-09-17) in case anyone finds > this useful. The core issue is that ld.bfd is currently setup to use > the GCC LTO plugin, which produces its IR in an ELF container, and > we don't. As a result, ld.bfd needs to ask the plugin if it would > like to claim files of unknown format (in addition to querying for > recognized object files). > > -Hal > > P.S. For the record, I'm certainly not a binutils expert, this just > seems to work for me. > > ----- Original Message ----- > > On 1 August 2012 23:00, Sun, Rui <rui.sun at intel.com> wrote: > > > Hi, > > > > > > > > > > > > I am trying to use LLVM LTO. I read > > > http://llvm.org/docs/GoldPlugin.html and > > > have some questions. Could anyone help? > > > > > > > > > > > > 1. Can LLVMgold.so work with BFD LD instead of gold? In the > > > description of changes in binutils 2.20, “* The plugin target has > > > been added > > > to bfd. It can load the same shared objects > > > > > > used by gold and uses them to provide basic support for new file > > > formats.”. > > > Does this mean BFD LD after 2.20 can support LLVMgold.so? Ld > > > version on my > > > system is: > > > > > > GNU ld (GNU Binutils for Ubuntu) 2.21.53.20110810 > > > > > > > In theory it can, but I think it is completely untested. I think > > that, as with gold, you have to build it with --enable-plugins. > > > > > > > > 2. Gold only supports ELF. If BFD LD can support LLVMgold, > > > can LTO be > > > applied to COFF objects after recompiling the binutils with > > > target==x86_64-pc-pe? > > > > Double untested, but I guess it could be made to work :-) > > > > > > > > Thanks! > > > > > > Rui > > > > > > > > > > Cheers, > > Rafael > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > -- > Hal Finkel > Assistant Computational Scientist > Leadership Computing Facility > Argonne National Laboratory-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory -------------- next part -------------- A non-text attachment was scrubbed... Name: ldbfd-bin-plugin-v2.patch Type: text/x-patch Size: 3086 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131011/00acaa93/attachment.bin>
You should probably send them for review/inclusion in bfd. On 11 October 2013 12:39, Hal Finkel <hfinkel at anl.gov> wrote:> Quick update: the previous patch only worked for static linking; this version should work for both static and dynamic linking. > > I'm not going to send any more updated patches to this list, but please feel free to e-mail me off-list, and I'll be happy to share any updates I have at any point in the future. > > -Hal > > ----- Original Message ----- >> Rafael, Rui, >> >> This is obviously an old thread, but in case there is interest, I've >> been able to get this to work (using the LLVM gold plugin with the >> ld.bfd linker). This requires some additional logic in the ld.bfd >> linker (and a small change to the bfd library). I've attached the >> patch (against binutils HEAD from 2013-09-17) in case anyone finds >> this useful. The core issue is that ld.bfd is currently setup to use >> the GCC LTO plugin, which produces its IR in an ELF container, and >> we don't. As a result, ld.bfd needs to ask the plugin if it would >> like to claim files of unknown format (in addition to querying for >> recognized object files). >> >> -Hal >> >> P.S. For the record, I'm certainly not a binutils expert, this just >> seems to work for me. >> >> ----- Original Message ----- >> > On 1 August 2012 23:00, Sun, Rui <rui.sun at intel.com> wrote: >> > > Hi, >> > > >> > > >> > > >> > > I am trying to use LLVM LTO. I read >> > > http://llvm.org/docs/GoldPlugin.html and >> > > have some questions. Could anyone help? >> > > >> > > >> > > >> > > 1. Can LLVMgold.so work with BFD LD instead of gold? In the >> > > description of changes in binutils 2.20, “* The plugin target has >> > > been added >> > > to bfd. It can load the same shared objects >> > > >> > > used by gold and uses them to provide basic support for new file >> > > formats.”. >> > > Does this mean BFD LD after 2.20 can support LLVMgold.so? Ld >> > > version on my >> > > system is: >> > > >> > > GNU ld (GNU Binutils for Ubuntu) 2.21.53.20110810 >> > > >> > >> > In theory it can, but I think it is completely untested. I think >> > that, as with gold, you have to build it with --enable-plugins. >> > >> > > >> > > 2. Gold only supports ELF. If BFD LD can support LLVMgold, >> > > can LTO be >> > > applied to COFF objects after recompiling the binutils with >> > > target==x86_64-pc-pe? >> > >> > Double untested, but I guess it could be made to work :-) >> > >> > > >> > > Thanks! >> > > >> > > Rui >> > > >> > > >> > >> > Cheers, >> > Rafael >> > >> > _______________________________________________ >> > LLVM Developers mailing list >> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >> >> -- >> Hal Finkel >> Assistant Computational Scientist >> Leadership Computing Facility >> Argonne National Laboratory > > -- > Hal Finkel > Assistant Computational Scientist > Leadership Computing Facility > Argonne National Laboratory