[LLVMdev] Shared libs?

Albert Graef Dr.Graef at t-online.de
Mon Jun 9 04:29:37 PDT 2008


Eli Friedman wrote:
> This isn't first-hand, but from what I remember hearing on IRC,
> putting llvm into shared libraries caused a ridiculous explosion in
> dynamic linking (and therefore startup) times.  So there is no option
> to make shared libraries, at least at the moment.

Well, by tweaking configure and make options, I've managed to build LLVM
2.2 shared libraries on Linux (x86), and they seemed to work fine. (I
did have to work around a circular dependencies error, though.)

This makes a *lot* of sense. E.g., my application is a functional
language interpreter (http://pure-lang.sf.net) which has to be linked
against most of LLVM, and it makes a whole lot of a difference to have
those 8+MB of libraries being handled by the dynamic linker instead of
including them all in a fat interpreter executable, for the same reason
that you don't want each and every C/C++ application to link libc and
the C++ library statically. Just imagine that you have 50 instances of
the interpreter running simultaneously!

Note that you can also work around this by just linking the static LLVM
libs into a shared lib which in turn is linked against your application.
That's what I actually do with my interpreter now, since the users
shouldn't have to tweak the LLVM stuff just to build my interpreter.
(Unfortunately, that approach doesn't work on x86-64 with LLVM 2.2,
since some parts of the LLVM JIT apparently contain non-relocatable
code; I hope that this will be fixed in the forthcoming LLVM 2.3.)

Albert

-- 
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de
WWW:    http://www.musikinformatik.uni-mainz.de/ag



More information about the llvm-dev mailing list