- GraalVM Updater
- Native Image
- Polyglot Programming
- Embedding Reference
- JVM Languages Reference
- LLVM Languages Reference
- Compiling Native Projects to LLVM Bitcode
- Limitations and Differences to Native Execution
- GraalVM LLVM Runtime Debugging
- LLI Command Options
- LLVM Compatibility
- Python Reference
- Python Reference
- R Reference Manual
- Ruby Reference
- WebAssembly Reference
GraalVM LLVM Runtime
The GraalVM LLVM runtime can execute programming languages that can be transformed to LLVM bitcode. This includes languages like C/C++, Fortran and others.
In contrast to static compilation that is normally used for LLVM based
languages, GraalVM implementation of the
lli tool first interprets the bitcode and then dynamically compiles the
hot parts of the program using the GraalVM compiler. This allows seamless
interoperability with the dynamic languages supported by GraalVM.
Running LLVM bitcode programs on GraalVM #
The syntax to execute programs in LLVM bitcode format with GraalVM is:
lli [LLI Options] [GraalVM Options] [Polyglot Options] <bitcode file> [program args]
Note: LLVM bitcode is platform dependent. The program must be compiled to bitcode for an appropriate platform.
Compiling to LLVM bitcode format #
GraalVM can execute C/C++, Fortran, and other programs that can be compiled to LLVM bitcode. For that, GraalVM needs the binaries to be compiled with embedded bitcode. The Compiling guide provides information on the expected file format and on compiling to bitcode.
Quick Start #
GraalVM comes with a pre-built LLVM toolchain for compiling C/C++ to LLVM bitcode. It is used as follows:
# install the toolchain (only needed once) $GRAALVM_HOME/bin/gu install llvm-toolchain # get the path to the toolchain export LLVM_TOOLCHAIN=$($GRAALVM_HOME/bin/lli --print-toolchain-path) # compile a C file using the bundled `clang` $TOOLCHAIN_PATH/clang example.c -o example # run the result on GraalVM $GRAALVM_HOME/bin/lli example
See the Compiling guide for more details.