These instructions assume you have built Julia from source. If you want to use it independent of Julia, please see the instructions in the repo README instead.
Build julia from source
Generate julia output
.bc file with
Convert julia output
.c and compile
Start by defining the directory of the julia src root folder where you have previously built an (unmodified) version of julia master (
>=v0.5-) as an environment variable:
# Build LLVM 3.7.1, for example, here we build it in-tree make -C $JULIA_ROOT/deps compile-llvm LLVM_VER=3.7.1 # installs llvm-cbe to $JULIA_ROOT/deps/build/llvm-3.7.1/build_Release/Release/bin git clone [email protected]:JuliaComputing/llvm-cbe.git $JULIA_ROOT/deps/srccache/llvm-3.7.1/projects/llvm-cbe make -C $JULIA_ROOT/deps/build/llvm-3.7.1/build_Release/projects
Follow the steps in my previous blog post to create a
.bc file with the desired content.
.c) and build
llvm-cbe binary on this LLVM bitcode file converts it into C program:
$JULIA_ROOT/deps/build/llvm-3.7.0/build_Release/Release/bin/llvm-cbe sys-plus.bc -o sys-plus.cbe.c
This output file then can be integrated into your normal toolchain and should work with your compiler. For
clang, I have tested with the following flags to suppress uninteresting lint flags while demonstrating compliance to the standard:
WARN='-std=c99 -pedantic -Wall -Wextra -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter -Wno-sign-compare -Wno-unused-but-set-variable -Wno-long-long -Wno-invalid-noreturn'
The resulting output than can be used in the place of the default system image (with JIT compilation disabled):
or it could be linked into a larger embedded application executable and initialized with the embedding api:
jl_options.compile_enabled = JL_OPTIONS_COMPILE_OFF; jl_options.image_file = argv; julia_init(JL_IMAGE_CWD);