Hi, 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 { entry: %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! Yuelu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120929/5d4faa13/attachment.html>
Hi Yuelu,> 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....> define i32 @pthread_equal(i32 %__thread1, i32 %__thread2) nounwind readnone > inlinehint { > entry: > %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.on most platforms pthread functions will get some kind of weak linkage that permits multiple definitions. What platform are you on? I suggest you create a trivial program that uses pthreads, compile it and send the preprocessed source to the mailing list (assuming that in the bitcode pthread equal turns up like this: with a body but without a special linkage type). Ciao, Duncan.
Apparently Analagous Threads
- [LLVMdev] A question about LICM (Loop Invariant Code Motion)
- [LLVMdev] Question on Fence Instruction
- [LLVMdev] A question about LICM (Loop Invariant Code Motion)
- [LLVMdev] A question about LICM (Loop Invariant Code Motion)
- [LLVMdev] Question on Fence Instruction