[LLVMdev] bytecode -> native code

Chris Lattner sabre at nondot.org
Tue Mar 22 21:14:47 PST 2005


On Tue, 22 Mar 2005, Tanu Sharma wrote:
> I am trying to obtain native code from the bytecode by using commands:
>
> % llc hello.bc -o hello.s
>
> % gcc hello.s -o hello.native
>
>
>
> This is working for a simple program( a single source file) but when I 
> try to run it on grep utility (grep.bc) , it gives me the following 
> error:

__main is provided when linking the application with llvm-gcc by the LLVM 
"crtend" library.  Make SURE you actually link the program with llvm-gcc 
before you run llc on it.

For example, this won't work:

  llvm-gcc t.c -c -o t.bc; llc t.bc; gcc t.s

This will work:
   llvm-gcc t.c -o t; llc t.bc gcc t.s

-Chris

> $ llc grep.bc -o grep.s
>
> $ gcc grep.s -o grep.native
> /tmp/ccY3oNAA.o(.text+0x2f2f): In function `main':
> : undefined reference to `__main'
> collect2: ld returned 1 exit status
>
>
> How should i fix this?
>
> Thanks
>
> - T
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list