-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
I was mulling over the latest issue regarding JLLs eagerly loading libraries in their __init__() functions (in this case, MKL gets broken if CSL_jll loads libgomp first, since it conflicts with symbols loaded from libiomp5) and I think I might have a solution. The way I want to fix that is to have BB analyze libraries for their dependencies, and then instead of eagerly loading them at __init__() time, load them at first ccall or dlsym() time. The issue is that the code that exists in the wild right now is:
using libfoo_jll
ccall((libfoo, :fooify), ...)
If I could change the libfoo in there to libfoo(), I could run a function that JIT loads all the dependent libraries (on a library-by-library basis, no longer eargerly loading all libraries within a single JLL because I don't know which bindings the user is going to want to use) and then returns the SONAME. Unfortunately, that breaks basically every user code ever.
However, I had an idea; what if we created a LazilyLoadedLibrary type that contained within it a list of other LazilyLoadedLibrary types which were its dependencies, and the ccall() lowering (as well as dlsym() and other methods) was taught to load those? Then the work that the JLLs have to do is just to export these objects for use. I think it might be possible to maintain pretty good compatibility with the ecosystem if we change a type under their noses, rather than changing all of their syntax.
This would eliminate the vast majority of JLL __init__() methods, should speed up launch time, will fix some behavioral bugs, and moves us closer to JLLs being inert pieces of data, rather than code.