[LLVMdev] Questions about linking with math library using llvm

Xun Li lxfind at gmail.com
Mon Mar 14 15:19:36 PDT 2011


Hi,

I have been trying to figure this out for a long time and really need some
help.
I am compiling C programs which uses some math functions (such as pow, ceil)
into SPARC ISA, using llvm-gcc.
I imagine below is the right process:
llvm-gcc -c -emit-llvm *.c
llvm-ld -lm *.bc -o test
llc -march=sparc test.bc -o test.s

However when I look into test.s, I realized that those math functions are
not linked in.
This can be also seen if I use "llc test.bc -o test.s" to generate the
assembly for the local machine and run "gcc test.s", it will prompt the
error saying that there are undefined reference to math functions. So the
"-lm" option in llvm-ld really did not link the math functions.
How could I link those math functions into the compiled assemblies?
Thanks.
-- 
Xun Li
Computer Architecture Lab
Department of Computer Science
University of California, Santa Barbara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110314/11e1fc23/attachment.html>


More information about the llvm-dev mailing list