[LLVMdev] LLVMdev Digest, Vol 93, Issue 5

Christopher Jones chrisjones.lambda at gmail.com
Fri Mar 2 16:15:52 PST 2012


Duncan, thanks!  I needed libffi.  Everything is fine now. Matt, thanks for the explanation of why clang worked with a simple C example and clang++ didn't seem to with a simple C++ example.

Chris

On Mar 2, 2012, at 10:05 AM, llvmdev-request at cs.uiuc.edu wrote:

> first off you need to build with FFI support (configure with --enable-libffi).
> Then you doubtless need to pass libstdc++ to lli, like this (IIRC):
> -load=libstdc++.so
> When you compile with clang++ it automagically adds the C++ standard library
> to the list of things to link with, which is why you don't notice that the
> linker is getting passed libstdc++.so.  As lli is doing linking too, it also
> needs libstdc++.so.
> 
> Ciao, Duncan.
> 

On Mar 2, 2012, at 10:05 AM, llvmdev-request at cs.uiuc.edu wrote:

> hello.bc doesn't contain the libstdc++ bits your program needs (iostream 
> and its (many) dependencies).  When you produce an executable, clang 
> tells the linker to link your binary with libsupc++, libstdc++, and 
> others, so the dynamic linker can satisfy your iostream dependencies at 
> runtime.  When running under lli, the interpreter will provide *a few* 
> basic functions for you (see 
> lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp), but things like 
> exit(), abort(), printf(), and scanf(), nothing as complicated as 
> libstdc++.  So if the function you need is not in the short list 
> provided by the interpreter itself, it will try to find your function 
> using libffi (if you compiled it in).  If that doesn't work, you'll get 
> errors like the below.
> 
> One solution would be to try to generate a single big .bc file that is 
> "statically linked" with all your dependencies (for some clues as to 
> what these are, try "ldd ./hello" on your clang++-generated binary.  
> Unfortunately, I'm no expert on this or any other methods of informing 
> lli about your .bc file's dependencies and where they can be found when 
> your interpreted program calls out to them.
> 
> -Matt





More information about the llvm-dev mailing list