-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier for embedded Julia to use a custom system image #32614
Comments
The bindir-locating code in The alternative check, performed in I suggest we always do the |
@staticfloat Is there an issue for the faulty bindir-locating code or would you like me to create one? I was just hit by it on Debian, the embedding example fails:
This also causes trouble for anyone who wishes to use Julia in R via JuliaCall: JuliaInterop/JuliaCall#99 It can be worked around by hardcoding Perhaps we can pass |
…nstalls) Julia's embedding fails in jl_init if Julia is built and installed with MULTIARCH_INSTALL=1, which it is in Debian and Ubuntu. It fails with: > julia_setup() Julia version 1.5.2 at location /usr/bin will be used. ERROR: could not load library "/usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so" /usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so: cannot open shared object file: No such file or directory The problem is described at JuliaLang/julia#32614 (comment). As a workaround, let's allow overriding the bindir by setting JULIA_BINDIR environment variable (`/usr/bin` to fix this on Debian). Fixes: JuliaInterop#99
…nstalls) Julia's embedding fails in jl_init if Julia is built and installed with MULTIARCH_INSTALL=1, which it is in Debian and Ubuntu. It fails with: > julia_setup() Julia version 1.5.2 at location /usr/bin will be used. ERROR: could not load library "/usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so" /usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so: cannot open shared object file: No such file or directory The problem is described at JuliaLang/julia#32614 (comment). As a workaround, let's allow overriding the bindir by setting JULIA_BINDIR environment variable (`/usr/bin` to fix this on Debian). Fixes: JuliaInterop#99
There is a WIP branch that is attempting to solve a lot of the embedding problems, including the JULIA_BINDIR requirement, but it's not passing tests yet: #38160 |
Oh, I'm sorry, I misread this issue, I had two different issues mixed up in my head. :) The loading story in v1.6 is changing somewhat (as evidenced by that PR) and in particular, we will have the option to be much more flexible in how we find libraries. In that PR, we explicitly find the location of the |
@staticfloat Yes, I believe that explicit knowledge of where Thanks for your quick answer, btw. :-) |
…nstalls) Julia's embedding fails in jl_init if Julia is built and installed with MULTIARCH_INSTALL=1, which it is in Debian and Ubuntu. It fails with: > julia_setup() Julia version 1.5.2 at location /usr/bin will be used. ERROR: could not load library "/usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so" /usr/lib/x86_64-linux-gnu/../bin/../lib/x86_64-linux-gnu/julia/sys.so: cannot open shared object file: No such file or directory The problem is described at JuliaLang/julia#32614 (comment). As a workaround, let's allow overriding the bindir by setting JULIA_BINDIR environment variable (`/usr/bin` to fix this on Debian). Fixes: JuliaInterop#99
I'm keenly interested in this capability. Does anyone have an example of embedding julia in C but loading a custom system image? In particular what libraries do you have to replace/overwrite to get it to work? If I can't get this sorted out they may just toss julia out of the solution space for our commercial project. We need to call julia functions from the java virtual machine. |
There is complete code for this in https://github.com/GunnarFarneback/DynamicallyLoadedEmbedding.jl. |
@GunnarFarneback thanks for the link. It should help. |
PackageCompiler does a great job at producing custom system images but deploying them for embedded targets is more complicated than it needs to be.
With the default system image, initializing embedded Julia is a simple matter of calling
jl_init()
. Under the hood this does dynamic loading introspection to find which library it is defined in (i.e.libjulia
) and where this library lives on the filesystem, then deduces Julia'sbindir
from this information. After this it just callsjl_init_with_image
with thebindir
and the default relative location of the system image.With a custom system image, the simplest way to initialize ought to be to call
jl_init_with_image(NULL, system_image_path)
. However, theNULL
first argument does something completely different thanjl_init
to determinebindir
. Specifically it first checks the presence of theJULIA_BINDIR
environment variable. If not present it usesuv_exepath
to deducebindir
. The latter may be fine when initializing thejulia
binary, but for embedded julia it finds the path to the embedding executable, which typically lives somewhere else.The result is that the embedding program needs to replicate the introspection done in
jl_init
itself, or have other ways of knowing where to find Julia'sbindir
. This is quite unnecessary since the code is already there injl_init
, just not available for this use case.Suggestion:
jl_init()
is changed to an alias forjl_init_with_image(NULL, NULL)
.jl_init_with_image
replaces theuv_exepath
based lookup with the code currently employed injl_init
.This has two potentially breaking consequences:
jl_init
will honor theJULIA_BINDIR
environment variable. This seems mostly like a positive change.jl_init_with_image(NULL, ...)
will depend on the location oflibjulia
instead of the location of the executable. Will this be an acceptable change? Specifically, will it work properly with thejulia
executable itself?The text was updated successfully, but these errors were encountered: