I am profiling a few files in Spec2K6 benchmark with a profiler written in LLVM, and cannot understand what is the correct way to link multiple .bc files.
For example, the benchmark has concat.c, which uses the xmalloc method defined in xmalloc.c, which uses xexit method from xexit.c
I am using the following commands to link multiple .bc files before I profile them -
CFLAGS='-D_GNU_SOURCE -D_XOPEN_SOURCE=600 -c -Wall -pedantic -Wno-long-long -g -O0 - I/net/x/silkyar/llvm/include -I/net/403.gcc/src'
clang $CFLAGS -emit-llvm -c 403.gcc/src/concat.c -o concat.bc
clang $CFLAGS -emit-llvm -c 403.gcc/src/xexit.c -o xexit.bc
clang $CFLAGS -emit-llvm -c 403.gcc/src/xmalloc.c -o xmalloc.bc
llvm-link concat.bc xexit.bc xmalloc.bc -o a.bc
llc a.bc -o a.s
g++ -o final a.s
./final
but this fails with,
llvm-link: link error in 'xexit.bc': Linking globals named 'xexit': symbol multiply defined!
/tmp/ccUldT0Y.o:(.debug_info+0x1e): undefined reference to .Lline_table_start0'
/tmp/ccUldT0Y.o:(.debug_info+0x42f): undefined reference to
.Lline_table_start1'
/tmp/ccUldT0Y.o:(.debug_info+0x4a0): undefined reference to `.Lline_table_start2'
collect2: ld returned 1 exit status
Could anyone please guide me on how llvm-link works.
Thanks.