I need a bit of help from the experts. I’m continuing Joosep Pata’s work on ROOT.jl, a package that makes it possible to use CERN ROOT from Julia (via Cxx.jl). Cxx.jl alone is not enough, however, because ROOT-6 brings it’s own LLVM-based C++ backend, and really doesn’t like to see Julia’s LLVM instance. Joosep managed to work around the problem by making ROOT.jl create a special Julia executable that first initializes ROOT and then starts Julia: https://github.com/JuliaHEP/ROOT.jl/blob/master/deps/ui.cc (for the history, see this thread.)
I’m trying to update this for Julia v0.6 - and it almost works as it is, but I ran into a problem with JULIA_HOME
: If I use the default Julia executable, JULIA_HOME
is set correctly (naturally). If I copy the standard Julia executable to a different path and set JULIA_HOME
via the environment variable $JULIA_HOME
, everything is fine too, of course. But if I run the Julia executable built from ROOT.jl’s “ui.cc”, then JULIA_HOME
is set to
“[…]/julia/usr/lib” instead of “[…]/julia/usr/bin” and $JULIA_HOME
from the environment is ignored. As a result of the wrong value of JULIA_HOME
(lib dir instead of bin dir), package pre-compilation fails when triggered from the ROOT-compatible Julia executable.
I’ve narrowed this down to the fact that ROOT.jl’s “ui.cc” uses
jl_init()
which calls
jl_init_with_image(libjldir, jl_get_default_sysimg_path())
(in “repl.c”) which in turn sets jl_options.julia_home
to libjldir
. This is a bit confusing, actually, as the first argument of jl_init_with_image
is actually named julia_home_dir
- I don’t quite get why libjldir
passed as the value. Then, when jl_resolve_sysimg_location is run
, it won’t touch jl_options.julia_home
because it’s already set.
The default Julia executable, however, uses
julia_init(jl_options.image_file_specified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME)
which bypasses jl_init
and jl_init_with_image
, so that jl_resolve_sysimg_location
finds jl_options.julia_home
unset and then sets it correctly.
So, here’s my two questions for the experts:
-
Is the behavior of
jl_init
to ignoreJULIA_HOME
and setjl_options.julia_home
to the lib instead of the bin directory intentional? Somehow this was different in v0.5. -
Should I use
jl_init
(according to the “Embedding Julia” section in the Julia docs) orjulia_init
(and if the latter, what do I need to link in to get access tojl_options
)?
Any advice would be very much appreciated.