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?