LLVM Python binding


I am developing an application which is Python based and uses LLVM. I use LLVM by generating textual bitcode files and feeding them to my plug-in. I wish LLVM had Python binding.

I would love to see Python binding as one of the GSoC projects so someone from the community can pick it up.



I’d might think about that, I have created quite a few Python bindings and, oddly enough, do enjoy it, probably just because of how easy boost::python makes it (I have always manually done it directly using that, but because of the sheer size of LLVM I may use a code generator to generate the basics, and yes I know how to manually create python C modules without any binder, but boost::python drastically cuts down the time for all the glue code). What would you be looking at, the same C++ interface for generating the bytecode (the Module, Value, etc… and so forth) in addition to what other functions would you want? I have only written a LLVM generator for a toy language so this may be beneficial for both you (in getting Python bindings) and me (in learning the full interface and what is really required). Bindings are easy to extend and (thanks to boost::python if I used it) the interface stays very type-safe for any C-style bindings.

The python setup system makes it easy to compile and install in the python distribution on any OS so it should literally be as easy as just downloading it and running setup.py in its root directory (or easy_install if added to the python cheeseshop). If you really wanted it to be done manually without external libraries (and the parts of boost I use can be included in the distribution, so that would really be a non-issue unless there is some aversion to it) then it would take longer then the time I have free, whereas with boost::python I could probably get something working with the main interfaces in a couple of days, and depending on the size of the LLVM interface that would be wanted, a month or so, with more time to make test-cases to make sure it works correctly.

Any thoughts on it being made into a GSoC project, or should I do it on my own (much less incentive to get it done quickly as I have other paying things to deal with, I would still get it done if started, just take longer to get fully finished)?

Also, have you looked at PyPy? It is no where near finished (or honestly, anywhere near usable on the front-end), but it has an LLVM back-end, might work well enough for now depending on what you are doing.

OvermindDL1 wrote:

because of the sheer size of LLVM I may use a code generator to generate the basics

For what it is worth, I have had a good experience using the Py++
binding generator in another project.