I’m using PackageCompiler.jl to build a shared library, so that I can integrate one of my algorithms into a C++ simulation. The C++ simulation is multi-threaded. We’d like to call the Julia algorithm on a thread other than the main thread. When we call into the shared library from anything other than the main thread, though, it hangs.
Does the explanation in the embedding docs apply to PackageCompiler, or does it have additional restrictions? If the embedding docs are appropriate, then it seems that as long as all of my calls to the shared library (including init_julia) happen on the worker thread, it should be fine. But like I said, the simulation hangs.
I ended up keeping all of my calls into the shared library on the main thread and handling the async on the Julia side. But I’d still love to learn more about what is possible with PackageCompiler.jl (and JuliaC.jl for that matter). Are they both required to run on the main thread? Is there documentation somewhere of these requirements/restrictions? If you can run it on a child thread, are there any examples to study?
I haven’t used this feature in a while. Also not tried it yet with JuliaC libraries (though I believe those should have all the functionalities of PackageCompiler.jl libraries, plus some more extra features)
Hi, can you reference the basis for your claim? The documentation on both, PackageCompiler and JuliaC, doesn’t mentioning the relation to the embedding section of the Julia manual.
This is based on personal tests with 1.11/1.12, and conversations with developers of core Julia. I did not try calling the function 70 times, but what used to crash immediately on jl_init() no longer does.
PackageCompiler should have (at least) the same limitations as regular Julia, so there isn’t anything to document there. The 1.12 change is part of some wider internal refactoring in the Julia compiler, but I’m afraid I cannot help you there.