Taaitaaiger / jlrs

Julia bindings for Rust
MIT License
408 stars 21 forks source link

Ship rust application with libjulia #79

Open Roger-luo opened 1 year ago

Roger-luo commented 1 year ago

It'd be very useful if we can ship a rust application with libjulia get included, I assume this should be possible if there is some kind of fake -src crate created for libjulia and let it finds local Julia and copy the shared library?

Taaitaaiger commented 1 year ago

I don't think such a crate is necessary, rather the binary needs to be able to find the libraries it depends on at runtime, either through environment variables or by setting an rpath. I have never tested this, though.

Roger-luo commented 1 year ago

do we have something that finds libjulia at runtime already? so that we can ship a binary and link to system julia (or whatever other available) directly

Taaitaaiger commented 1 year ago

As I understand it, libjulia is dynamically linked, so as long as it can be found at runtime (via the Path environment variable on Windows, or LD_LIBRARY_PATH on Linux) it should be possible to use a binary compiled on another machine.

The only major limitation I expect is that the version of Julia must be compatible with jlrs, and that this version is used at compile time and runtime. It won't be possible to compile against Julia 1.6 and link against 1.8 at runtime, for example.

Roger-luo commented 1 year ago

Is this because Julia doesn't have a stable ABI yet?

Taaitaaiger commented 1 year ago

Yes. In my experience there are minor, but backwards-incompatible, changes every version. Sometimes it's the signature of a function, sometimes it's the layout of a type.

It would be nice if Julia had something similar to NAPI (I'm more familiar with that than Python FFI), but I've never really thought about what that should look like.

Op vr 7 apr. 2023 17:19 schreef Rogerluo @.***>:

Is this because Julia doesn't have a stable ABI yet?

— Reply to this email directly, view it on GitHub https://github.com/Taaitaaiger/jlrs/issues/79#issuecomment-1500383030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQBHH44EVOC3BQZGU437PLXAAWALANCNFSM6AAAAAAWVUUHPU . You are receiving this because you commented.Message ID: @.***>