Hi,all I have installed the gold-plugin and it can run correctly,but I still have another two questions: 1.Can gold-plugin generate a bitcode file:>From the document and also my experience on using it,"ld -plugin...."will only generate an executable by link several LLVM bitcode file together,but how to make it generate a whole-program bitcode file?(even archieve it manually is OK) 2.llvm-gcc -c will stop the linker to run: I have been trying to generate a whole-program bitcode file,but when I use CFLAGS="-emit-llvm -c" to compile source files into LLVM bitcode file,llvm-gcc will not call "ld" to link modules together,so that I cannot link these modules together automatically. How to overcome this trouble? Thank you !Best regards! Nan
zhunan wrote:> Hi,all > > I have installed the gold-plugin and it can run correctly,but I still > have another two questions: > > 1.Can gold-plugin generate a bitcode file:No. The task of linking many .bc files into a single .bc file falls on llvm-ld and llvm-link. A common followup question is "but how do I link native libraries into my .bc file". You don't. A .bc file is llvm ir, you can't put a native binary library into a .bc (barring sticking it in as a string, etc). The build then looks like: a) 'llvm-gcc -c -flo -O2' to generate the .bc files. b) 'llvm-ld' to combine them into a single .bc. No, not a .so nor a .a. c) 'llc' to turn your combined .bc into a .s d) 'as' to turn your .s into a .o e) 'ld' to turn your .o into a .so or final executable. This is the step where you get to specify all the native libraries to link with. You can use 'gcc' to merge steps d and e (it just runs as and ld for you). Or you can use the gold plugin to merge steps b through e, but with the added benefit that it will optimize slightly better. See the llvm LTO documentation on why.>>From the document and also my experience on using it,"ld -plugin...." > will only generate an executable by link several LLVM bitcode file > together,but how to make it generate a whole-program bitcode file?(even > archieve it manually is OK) > > 2.llvm-gcc -c will stop the linker to run: > > I have been trying to generate a whole-program bitcode file,but when I > use CFLAGS="-emit-llvm -c" to compile source files into LLVM bitcode > file,llvm-gcc will not call "ld" to link modules together,so that I > cannot link these modules together automatically. > > How to overcome this trouble?You get to modify your program's build system. Things like 'configure' work by trying to compile and run small programs. You can't run a .bc file. Nick
Sanjiv.Gupta at microchip.com
2009-Sep-21 06:57 UTC
[LLVMdev] ld with gold-plugin can do this?
A common followup question is "but how do I link native libraries into my .bc file". You don't. A .bc file is llvm ir, you can't put a native binary library into a .bc (barring sticking it in as a string, etc). The build then looks like: a) 'llvm-gcc -c -flo -O2' to generate the .bc files. b) 'llvm-ld' to combine them into a single .bc. No, not a .so nor a .a. c) 'llc' to turn your combined .bc into a .s d) 'as' to turn your .s into a .o e) 'ld' to turn your .o into a .so or final executable. This is the step where you get to specify all the native libraries to link with. You can use 'gcc' to merge steps d and e (it just runs as and ld for you). Or you can use the gold plugin to merge steps b through e, but with the added benefit that it will optimize slightly better. See the llvm LTO documentation on why. [Sanjiv] - This is what PIC16 does. llvm-ld has an option called '-b' that you can use to specify the output bitcode file name. Unfortunately, llvm-ld always tries to generate a native executable (or a shell script) as well and currently there is no way to disable that. Maybe an option like '-no-native' will be come handy. - Sanjiv -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090920/8d78b068/attachment.html>