[LLVMdev] Getting Started with LLVM

Eric Kidd emk.lists at gmail.com
Fri Mar 10 08:16:50 PST 2006


Hello!  I'm considering using LLVM for several different projects in
the future, so I'm conducting a technical evaluation.  So far, the
APIs and the benchmark results look absolutely great.

Things I really like:

1) LLVM is low-level enough to support most languages that run on
standard hardware.
2) The JIT examples are really straightforward.
3) The documentation is remarkably good.
4) The performance of generated code is comparable to GCC, at least on
the PowerPC.
5) The LLVM developers appear sufficiently ambitious to encourage
real-world use of LLVM. :-)

After reading the manuals, building llvm, and messing around with
llvm-gcc--all straightforward experiences--I copied HowToUseJIT.cpp to
a new directory and tried to build it. At this point, I hit the wall
fairly hard:

1) The only supported way to link against LLVM from outside the build
directory is to use Makefile.common and the LLVM build system, both of
which require an LLVM build tree. Without extensive customization:
  a) I can't link against the installed LLVM libraries and headers.
  b) I can't use my projects' pre-existing build systems (automake,
rake, or whatever).
2) In 1.6, the "sample" project can't be built outside the LLVM tree
without modifying AutoRegen.sh to find the llvm/autoconf/m4. The
published instructions omit this step.
3) The only documentation for building code against LLVM is in Makefile.rules.

Unfortunately, it looks like integrating LLVM with an existing project
is a fair bit of work. This is certainly a problem for us, and it
might have been a problem for several other compilers that I've
contributed to in the past[1].

Ideally, it would be easy to link toy programs against LLVM (or the
LLVM JIT) without using Makefile.common. This would would let existing
projects experiment with LLVM and get a quick win or two. One approach
might be to create an 'llvm-config' script similar to the ones
provided by many Unix libraries. This might be invoked as follows:

  g++ `llvm-config --cflags` -o HowToUseJIT.o -c HowToUseJIT.cpp
  g++ `llvm-config --ldflags` -o HowToUseJIT HowToUseJIT.o `llvm-config --ldadd`

Ideally, this script would build and link against the installed copy
of LLVM, not the source and object trees left over from the build. The
script would presumably provide options for including or omitting
various LLVM components.

So here's my proposal: If you might be interested in a tool like this,
I'd be happy to work out the details with you, write the necessary
code, and send you diffs against CVS HEAD. Please let me know if such
a patch (or something similar) would be a desirable addition to LLVM.

Cheers,
Eric

[1] I've contributed code to the open source version of Gywdion Dylan,
and to Jonathan Bachrach's Goo compiler. I've also worked on a
commercial embedded compiler and several toy compilers.




More information about the llvm-dev mailing list