[LLVMdev] Building LLVM as bitcode libraries + my projects

Bjarke Walling walling at daimi.au.dk
Tue Jan 1 15:30:49 PST 2008


Hi all,

Is it possible to build the LLVM tools and libraries as bitcode files?

I have managed to compile some software to bitcode files by creating a
wrapper around llvm-gcc, llvm-g++ and llvm-ld and some hacking. Using
binfmt in Linux you can even execute them directly on the command
line. The object format becomes transparent. I tried to compile LLVM
itself, but things go wrong with the tablegen tool. Missing symbols,
segmentation faults, libraries crashing. I have experienced various
errors and tried various fixes with no success. How do I correctly
link to libstdc++ using the lli tool?

I have ideas for two hobby projects I am really interested in. They
both require that LLVM can be compiled to bitcode.

1) Play around with Futamura projections, applying aggressive
optimizations to the LLVM library itself. The idea is to create a
partial evaluation tool that provides some "outer" optimizations
combined with the LLVM optimizations. For example you are able to tell
that a read-file should be actually executed as an "optimization". The
file content becomes static and optimized into the application. Then
you basically run the partial evaluation tool on itself and see what
happens. The requirement is that the tool including libraries it links
to (LLVM) are bitcode files.

2) Install Linux From Scratch with bitcode as the main object format.
I know I am a bit crazy. :-) I want to control which object files are
native and which are bitcode. My idea is that the most files should be
bitcode. The linux kernel, LLVM (the JIT/execution engine) and a
minimal set of support libraries are native files. Everything else (if
possible) is bitcode. The biggest problems is that some tools does not
exists yet. That includes tools in the binutils package, which are
used in many makefiles. I have compiled binutils as bitcode, but that
doesn't solve the problem that the tools don't recognize bitcode as a
valid object file format.

Why would I want to do these projects? Most for fun, but I also hope
to expand my knowledge. :-)

- Bjarke



More information about the llvm-dev mailing list