[LLVMdev] libstdc++ as bytecode, and compiling C++ to C

Mohd-Hanafiah Abdullah napi at axiomsol.com
Mon Nov 20 01:21:17 PST 2006


On Mon, 2006-11-20 at 17:49 +1100, Emil Mikulic wrote:
> I've compiled all the object files that make up libstdc++ and libsupc++
> into LLVM bytecode:
> 	http://goanna.cs.rmit.edu.au/~emil/libstdcxx.tar.bz2 (438KB)
> 
> A simple test program, x.cpp:
> 
> 	#include <iostream>
> 	int main() { std::cout << "hello world\n"; return 0; }
> 
> $ llvm-g++ -emit-llvm -c x.cpp
> $ llvmc -o=out x.o std/*.o sup/*.o
> $ lli out.bc
> Segmentation fault (core dumped)
> $
> 
> Oops, no go.  Try a different way:
> 
> $ llvm-g++ -emit-llvm -c x.cpp
> $ llvm-link -o=linked.o x.o std/*.o sup/*.o
> $ lli linked.o
> hello world

Emil:

Thanks for your email.  I tried the above and got the following errors:

$ llvm-link -o=linked.o x.o std/*.o sup/*.o
llvm-link: error loading file 'std/allocator-inst.o'

And when I do this:
$ llvmc -o=out x.o std/*.o sup/*.o
llvm-ld: error: Cannot load file 'std/allocator-inst.o'Bytecode file
'std/allocator-inst.o' could not be loaded: Unknown bytecode version
number: 6 (Vers=6, Pos=13)
llvmc: Action failed


I'm using LLVM 1.8.  Is it due to compatibility problem?

Thanks.

Napi





More information about the llvm-dev mailing list