I recently modified my compiler's build files to use clang if it detects its available, however I'm running into a number of problems with this. I'm having one set of problems on OS X, and a different set of problems under Ubuntu. In both cases I'm attempting to link my frontend - compiled with clang - against the LLVM libraries - compiled with gcc. (I thought about compiling LLVM with clang, but then I'd have to compile it twice to bootstrap.) Under OS X, I get the following error when I try to link: Undefined symbols: "___eprintf", referenced from: ___eprintf$non_lazy_ptr in libLLVMSupport.a(SearchForAddressOfSpecialSymbol.cpp.o) ld: symbol(s) not found clang-3: error: linker command failed with exit code 1 (use -v to see invocation) As you can see the reference is coming from the LLVM libs. Under Ubuntu, the problem I get is a crash when calling a method in DIBuilder. The problem appears to be in the StringRef param, which looks like it's full of junk when I examine it in the debugger, even though my code is just passing in the default value for the parameter, which is an empty StringRef(). I'm guessing there is some incompatibility in the calling conventions, but I'm passing virtually the same command-line arguments to clang as I would normally pass to gcc. (With some minor differences having to do with warning suppression). -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110512/ca77e9ca/attachment.html>
Rafael Ávila de Espíndola
2011-May-13 01:08 UTC
[LLVMdev] Difficulty compiling LLVM-based tools with clang
On 11-05-12 8:33 PM, Talin wrote:> I recently modified my compiler's build files to use clang if it detects > its available, however I'm running into a number of problems with this. > I'm having one set of problems on OS X, and a different set of problems > under Ubuntu. > > In both cases I'm attempting to link my frontend - compiled with clang - > against the LLVM libraries - compiled with gcc. (I thought about > compiling LLVM with clang, but then I'd have to compile it twice to > bootstrap.) > > Under OS X, I get the following error when I try to link: > > Undefined symbols: > > "___eprintf", referenced from: > > ___eprintf$non_lazy_ptr in > libLLVMSupport.a(SearchForAddressOfSpecialSymbol.cpp.o) > > ld: symbol(s) not found > > clang-3: error: linker command failed with exit code 1 (use -v to > see invocation) >Interesting. A coworker had exactly the same problem trying to build rust with clang after having built llvm with gcc. The problem comes from SearchForAddressOfSpecialSymbol.cpp: // FIXME: Currently disabled when using Clang, as we don't always have our // runtime support libraries available. #ifndef __clang__ #ifdef __i386__ EXPLICIT_SYMBOL(__eprintf); #endif #endif Now, exactly what runtime library is not available is something that someone more familiar with OS X will have to answer :-)> -- > -- TalinCheers, Rafael
Charles Davis
2011-May-13 01:15 UTC
[LLVMdev] Difficulty compiling LLVM-based tools with clang
On 5/12/11 7:08 PM, Rafael Ávila de Espíndola wrote:> The problem comes from SearchForAddressOfSpecialSymbol.cpp: > > // FIXME: Currently disabled when using Clang, as we don't always > have our > // runtime support libraries available. > #ifndef __clang__ > #ifdef __i386__ > EXPLICIT_SYMBOL(__eprintf); > #endif > #endif > > Now, exactly what runtime library is not available is something that > someone more familiar with OS X will have to answer :-)The runtime support library the comment talks about is none other than compiler-rt. (Specifically, libclang_rt.eprintf.a.) If you check out compiler-rt into <llvm-src>/projects/compiler-rt, clang will pick it up and build it automatically. Chip