I truly get the bytecode file for each souce file,but can I use llvm-link to link them into a whole-program one automatically through some scripts?> > Message: 27 > Date: Tue, 15 Sep 2009 03:16:10 +0200 > From: ?scar Fuentes <ofv at wanadoo.es> > Subject: Re: [LLVMdev] Replace gcc with llvm-gcc??? > To: llvmdev at cs.uiuc.edu > Message-ID: <87vdjlnh2d.fsf at telefonica.net> > Content-Type: text/plain; charset=windows-1252 > > zhunan <zhunansjtu at gmail.com> writes: > > > Recently I met a question when I want to replace gcc with llvm-gcc > > through configure script(command). > > > > For simply,described like that > > > > I typed as following > > > > 1.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-S > > -emit-llvm" > > > > configure will failed when it checks whether C compiler is working > > > > 2.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-c > > -emit-llvm" > > > > configure will failed when it checks the default output filename,just > > means the C compiler cannot create executables. > > > > > > I would like to know what's the matter with this replacing attempt?and > > any possibility to overcome the trouble? > > Your CFLAGS is telling llvm-gcc that it must not produce an object code > file nor an executable file, but something else (llvm assembler on your > first attempt and llvm bitcode on your second attempt). > > `configure' needs a fully working compiler toolset, which means that the > compiler must be able to produce executable files. Your CFLAGS setting > is preventing this. > > Execute `configure' with just CC=llvm-gcc and then try > > make CFLAGS="-emit-llvm" > > if you want LLVM bitcode or > > make CFLAGS="-S -emit-llvm" > > if you want LLVM assembler. > > `make' will fail at the linking phase, but you will have a set of LLVM > bitcode/assembler files for each of your C source files. > > If you simply want to replace gcc with llvm-gcc for building your > software, forget about CFLAGS and just do > > ./configure CC=llvm-gcc && make >
Just set llvm-ld as the default ld . Such as LD = llvm-ld in makefile, if it's not working, then there is no solution 2009/9/15, zhunan <zhunansjtu at gmail.com>:> I truly get the bytecode file for each souce file,but can I use > llvm-link to link them into a whole-program one automatically through > some scripts? > > >> >> Message: 27 >> Date: Tue, 15 Sep 2009 03:16:10 +0200 >> From: ?scar Fuentes <ofv at wanadoo.es> >> Subject: Re: [LLVMdev] Replace gcc with llvm-gcc??? >> To: llvmdev at cs.uiuc.edu >> Message-ID: <87vdjlnh2d.fsf at telefonica.net> >> Content-Type: text/plain; charset=windows-1252 >> >> zhunan <zhunansjtu at gmail.com> writes: >> >> > Recently I met a question when I want to replace gcc with llvm-gcc >> > through configure script(command). >> > >> > For simply,described like that >> > >> > I typed as following >> > >> > 1.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-S >> > -emit-llvm" >> > >> > configure will failed when it checks whether C compiler is working >> > >> > 2.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-c >> > -emit-llvm" >> > >> > configure will failed when it checks the default output filename,just >> > means the C compiler cannot create executables. >> > >> > >> > I would like to know what's the matter with this replacing attempt?and >> > any possibility to overcome the trouble? >> >> Your CFLAGS is telling llvm-gcc that it must not produce an object code >> file nor an executable file, but something else (llvm assembler on your >> first attempt and llvm bitcode on your second attempt). >> >> `configure' needs a fully working compiler toolset, which means that the >> compiler must be able to produce executable files. Your CFLAGS setting >> is preventing this. >> >> Execute `configure' with just CC=llvm-gcc and then try >> >> make CFLAGS="-emit-llvm" >> >> if you want LLVM bitcode or >> >> make CFLAGS="-S -emit-llvm" >> >> if you want LLVM assembler. >> >> `make' will fail at the linking phase, but you will have a set of LLVM >> bitcode/assembler files for each of your C source files. >> >> If you simply want to replace gcc with llvm-gcc for building your >> software, forget about CFLAGS and just do >> >> ./configure CC=llvm-gcc && make >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- 从我的移动设备发送 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo
罗勇刚(Yonggang Luo) wrote:> Just set llvm-ld as the default ld . > Such as LD = llvm-ld in makefile, if it's not working, then there is no solution >Some Makefiles use the C compiler (e.g., gcc or llvm-gcc) as the linker. For such Makefiles, the above will not work because llvm-gcc runs ld. What you need is a linker that can link LLVM bitcode files together. If that is the case, then an alternative is to use the LLVM plugin for the gold linker (http://llvm.org/docs/GoldPlugin.html). If gold is your system linker (or you can make llvm-gcc use it instead of ld), then (I believe) you can get the Makefiles to transparently link LLVM bitcode files together into a single bitcode file. The above is for Linux. On Mac OS X, I think the linker with Xcode can link bitcode files together, but I'm not sure. Please note that I haven't tried this myself yet; it's one of the things I will try the next time I need to create a single bitcode file for an executable. -- John T.> 2009/9/15, zhunan <zhunansjtu at gmail.com>: > >> I truly get the bytecode file for each souce file,but can I use >> llvm-link to link them into a whole-program one automatically through >> some scripts? >> >> >> >>> Message: 27 >>> Date: Tue, 15 Sep 2009 03:16:10 +0200 >>> From: ?scar Fuentes <ofv at wanadoo.es> >>> Subject: Re: [LLVMdev] Replace gcc with llvm-gcc??? >>> To: llvmdev at cs.uiuc.edu >>> Message-ID: <87vdjlnh2d.fsf at telefonica.net> >>> Content-Type: text/plain; charset=windows-1252 >>> >>> zhunan <zhunansjtu at gmail.com> writes: >>> >>> >>>> Recently I met a question when I want to replace gcc with llvm-gcc >>>> through configure script(command). >>>> >>>> For simply,described like that >>>> >>>> I typed as following >>>> >>>> 1.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-S >>>> -emit-llvm" >>>> >>>> configure will failed when it checks whether C compiler is working >>>> >>>> 2.zhunan at sjtu:~/workplace/$ ./configure CC=llvm-gcc CFLAGS="-c >>>> -emit-llvm" >>>> >>>> configure will failed when it checks the default output filename,just >>>> means the C compiler cannot create executables. >>>> >>>> >>>> I would like to know what's the matter with this replacing attempt?and >>>> any possibility to overcome the trouble? >>>> >>> Your CFLAGS is telling llvm-gcc that it must not produce an object code >>> file nor an executable file, but something else (llvm assembler on your >>> first attempt and llvm bitcode on your second attempt). >>> >>> `configure' needs a fully working compiler toolset, which means that the >>> compiler must be able to produce executable files. Your CFLAGS setting >>> is preventing this. >>> >>> Execute `configure' with just CC=llvm-gcc and then try >>> >>> make CFLAGS="-emit-llvm" >>> >>> if you want LLVM bitcode or >>> >>> make CFLAGS="-S -emit-llvm" >>> >>> if you want LLVM assembler. >>> >>> `make' will fail at the linking phase, but you will have a set of LLVM >>> bitcode/assembler files for each of your C source files. >>> >>> If you simply want to replace gcc with llvm-gcc for building your >>> software, forget about CFLAGS and just do >>> >>> ./configure CC=llvm-gcc && make >>> >>> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > >