[LLVMdev] src to src conversion

Ryan M. Lefever lefever at crhc.uiuc.edu
Mon Apr 24 23:01:00 PDT 2006


I am trying to use LLVM as a source to source C compiler.  I use 
llvm-gcc to convert file.c->file.bc.  Then I use opt to run my own 
compiler passes to convert file.bc->file.opt.bc.  Then I use llc to 
convert file.opt.bc->file.opt.c.  Now, I want to use normal gcc to 
compile file.opt.c into an executable.  However, I'm getting the 
following errors:

test.opt.c:89: warning: conflicting types for built-in function 'malloc'
test.opt.o(.text+0xe7): In function `main':
: undefined reference to `__main'
collect2: ld returned 1 exit status
make: *** [test.opt.exe] Error 1

------

I think the problem with main and __main is that I need to link in some 
LLVM runtime libraries.  So, I tried to link in crtend (which defines 
__main).  However, I get the following error:

/home/testbed1/lefever/work/llvm/install/lib/libcrtend.a: could not read 
symbols: Archive has no index; run ranlib to add one
collect2: ld returned 1 exit status
make: *** [test.opt.exe] Error 1

I tried creating a copy of the libcrtend.a and running ranlib on it and 
I also separately tried running llvm-ranlib on it.  Neither of those 
actions worked though.  Am I linking the correct library, i.e., crtend? 
  Why am I getting the error about the archive having no index?

-----

As far as the warning about conflicting types for malloc, it appears 
that llvm is using the declaration where the output of malloc is a 
"signed char *" rather than "void *".  Why is that?

Thanks in advance for any help.

Regards,
Ryan

-- 
Ryan M. Lefever  [217.333.7231]  [http://www.ews.uiuc.edu/~lefever]




More information about the llvm-dev mailing list