JuliaLang / JuliaLang/PackageCompiler.jl

Embedding Julia in Scala

Open
#803 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Julia
Stars
1.6k
Forks
205
Avg merge
18h 37m
Merged PRs (30d)
7

Description

I'm trying a POC to see if it can be made possible, to embed Julia in scala.

I've proven that the Julia embedding guide works (fairly trivially), and that I can call Julia itself. This script,
https://github.com/Quafadas/slincTest/blob/master/slinc.scala

Produces this output;
```
WARNING: Using incubator modules: jdk.incubator.foreign
Got a quotient of 2 and a remainder of 1
41
18467
WARNING: failed to initialize stack walk info
Code supplied to Julia directly
1.4142135623730951
Now let's call a pre-compiled library

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
in expression starting at none:0
unknown function (ip: 0000000000000000)
Allocations: 2907 (Pool: 2896; Big: 11); GC: 0

```
This script first tests that we can call the C stdlib from scala. That's the 41 etc.

Calls to Julia kick in on the log line
`WARNING: failed to initialize stack walk info`

The embedding example successfully prints the square root of 2.

So now comes the question of whether it's possible to execute a pre-compiled Julia library through a C interface. My attempt at that via PackageCompiler, generates the exception you see above.

What I've done. Extracted this example;
https://github.com/JuliaLang/PackageCompiler.jl/tree/master/examples/MyLib

into it's own directory called MyLib, and then run, following the documentation;
```
create_library("MyLib", "MyLibCompiled";
lib_name="libinc",
precompile_execution_file="MyLib/build/generate_precompile.jl",
precompile_statements_file="MyLib/build/additional_precompile.jl",
header_files = ["MyLib/build/mylib.h"], force=true)
```
I posted up on Discourse yesterday, but that didn't help so much.
https://discourse.julialang.org/t/embedding-julia-in-scala/97347/2

- I'm following the documentation
- I can call "vanilla Julia"
- The message says "submit a bug report"

I _think_ this would be intended to work and in scope of the library, and as I'm using the example in the repo... it may justify the issue.

It could also be, that I have missed something. I've tried a variety of flavours of putting dlls in the right place, to no avail.

Notes; I'm on windows.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with slinc.scala and reproduce the Windows failure using the PackageCompiler.jl MyLib example and the documented create_library command. Read MyLib/build/generate_precompile.jl, MyLib/build/additional_precompile.jl, and MyLib/build/mylib.h, then compare the precompiled-library call with the working Julia embedding call. Done means determining whether this C-interface path is supported and documenting the cause or a minimal reproducible failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, scala
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.