LLVM Image Activator
John Baldwin
jhb at freebsd.org
Mon Jan 7 15:14:58 UTC 2013
On Sunday, January 06, 2013 01:02:21 PM Nathan Whitehorn wrote:
> Having LLVM/clang in the base system lets us do some interesting things
> that we couldn't do with GCC. One is that LLVM ships with a JIT for LLVM
> IR as well as components of a toolchain for it (this is what Google's
> pNACL uses) and that you can end up producing binary files that are in
> IR instead of native code. The IR isn't really cross-platform, but does
> let you do CPU-specific optimizations when executed by the JIT, etc.
>
> The attached patch causes the LLVM JIT (lli) to be built by default
> (adding ~20 seconds to buildworld on my five-year-old laptop) and adds a
> kernel image activator that invokes it when passed LLVM bitcode files.
> It's not completely finished (see the XXX comment in the middle), but it
> does work, as follows:
>
> $ clang -emit-llvm -c -o hw.ll hw.c
> $ file hw.ll
> hw.ll: LLVM bitcode
> $ lli hw.ll
> Hello world!
> $ chmod a+x hw.ll
> $ ./hw.ll
> Hello world!
> $
>
> Is there any interest in having features like this? It seems like this
> could provides some interesting possibilities for us and nice
> integration from having imported clang into base.
> -Nathan
This sounds neat indeed. Does the IR format provide any sort of notation for
encoding the path to the interpreter (similar to ELF)? If not, you might want
to at least make the path to 'lli' be configurable via a tunable and/or sysctl
(e.g. if using a newer version of clang in /usr/local).
--
John Baldwin
More information about the freebsd-arch
mailing list