Linking in the C++ standard library into LLVM bitcode

105 views
Skip to first unread message

Rohit

unread,
Feb 8, 2013, 3:03:07 PM2/8/13
to bi...@googlegroups.com
Hey David,

I am trying to use bitey to glue together Python and some C++ code that I have. The way I see it, bitey automates a lot of ctypes related work by getting type information from LLVM bitcode. So it should be possible to write a thin glue layer using extern "C" throughout, compile the glue code and the main code to LLVM bit code, link them together and then import via bitey.

This plan works great until I use cout and friends. From what I can tell, in the -emit-llvm steps, the code is compiled down to LLVM but it is not linked to the C++ standard library. Hence it complains at the import step that some reference is unresolved. There's no problem if the C standard library is used, since it is already linked in by the python interpreter itself. I have tried googling it out, but have not come across anything useful.

In other words,

$ clang++ -emit-llvm -c glue.cpp  # OK
$ clang++ -emit-llvm -c main.cpp # OK
$ llvm-ld glue.o main.o -b combined.o # ERROR : C++ stdlib is not availiable in this linking step

I know you have C++ scars ;) , and hence want bitey to have nothing to do with C++, but is there some llvm-fu of some kind that will do the trick?

Cheers,

Rohit
Reply all
Reply to author
Forward
0 new messages