[LLVMdev] Using llvm-gcc with a simple program and the '-c' option

Robert L. Bocchino Jr. bocchino at uiuc.edu
Sun Feb 26 21:12:02 PST 2006


The -c option tells llvm-gcc to build a bytecode file without linking 
in the LLVM runtime library.  This is similar to the -c option for 
regular gcc, which you use to build multiple separate .o files that 
you're going to link into a single executable.  If you want to build 
from a single source file, it's easiest just to compile without the -c 
option.  If you're building from multiple source files, you can either 
give them all to llvm-gcc at the same time with no -c option

	llvm-gcc foo.c bar.c -o foobar

or compile separately with -c and then link them together

	llvm-gcc -c foo.c -o foo.bc
	llvm-gcc -c bar.c -o bar.bc
	llvm-gcc foo.bc bar.bc -o foobar

You can also use llvm-ld for the last step.

Rob

On Sunday, February 26, 2006, at 10:02 PM, Wink Saville wrote:

> Hello,
>
> When I compile a "hello.c" program with a printf in "main" and use 
> llvm-gcc with a "-c" option:
>
>    llvm-gcc -c t1.c -o t1.bc
>
> and then try to compile t1.bc to native using llc & gcc I get a call 
> to "__main" which is undefined.
>
> If I don't use the "-c" option:
>
>    llvm-gcc t1.c -o t1
>
> I don't get a reference to "__main" and I can compile to native 
> without problem. Also, I created some simple modules without a "main" 
> and using the "-c" option and that works as expected. What am I doing 
> wrong?
>
> Thanks,
>
> Wink Saville
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
Robert L. Bocchino Jr.
1950 South Orchard St., Apt. A
Urbana, IL  61801
(217) 979-1053




More information about the llvm-dev mailing list