[LLVMdev] pthread_equal multiply defined in .bc files

Duan, Yue Lu duan11 at illinois.edu
Sat Sep 29 13:36:38 PDT 2012


When I tried to use the latest version of LLVM tools (clang as the frontend) to compile and link a project with multiple c files, it appears that each of the generated .bc file contains a definition of pthread_equal, resulting llvm-link failure with error message "multiply symbols defined". I tried but did not get any answer on the web.  So I turn to you for help.

Here is the command lines that I use to compile and link the files:

clang -O2 -emit-llvm -c *.c -o *.bc;

llvm-link *.bc -o BARNES.bc

Then I get this error:

llvm-link: link error in 'code_io.o': Linking globals named 'pthread_equal': symbol multiply defined!

After using llvm-dis to get the llvm assembly code, I found that in every .bc, pthread_equal is defined:

define i32 @pthread_equal(i32 %__thread1, i32 %__thread2) nounwind readnone inlinehint {
  %cmp = icmp eq i32 %__thread1, %__thread2
  %conv = zext i1 %cmp to i32
  ret i32 %conv

That results multiple definitions of the same function and the linkage error.

NOTE: The above compile and link method works for single C file program.

So what do I miss that can avoid this issue?

Thank you very much!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120929/5d4faa13/attachment.html>

More information about the llvm-dev mailing list