julia
07b80276 - Libdl: Avoid scanning filesystem when computing shlib dir (#62160)

Commit
30 days ago
Libdl: Avoid scanning filesystem when computing shlib dir (#62160) `dlpath(...)` is a bit of a footgun to the extent that it relies on either (1) exactly matching the SONAME (Unix) / filename (Windows) or (2) re-discovering the already-loaded library by the linker search path. The first check fails essentially automatically on Unixes, since we don't provide the versioned SONAME to this lookup (and we want to be able to change this after-the-fact when packaging Julia anyway). The fallback (2) also ends up occasionally unreliable, for the same reasons that we avoid `dlopen(...)` with relative paths / bare library names. On FreeBSD for example, `dlopen` uses a different linker search path than an equivalent `DT_NEEDED` entry (it uses the executable's rpath, not the library's). The solution is to avoid `dlpath` and instead ask the runtime directly: `jl_get_libjulia_internal_path` reports the shared library containing libjulia-internal, located through the address of a file-local object. Unlike the address of an exported symbol, which may resolve to a PLT stub or a copy relocation in another image, that address is always within libjulia-internal itself. If libjulia-internal is linked into the executable, there is no such library, and the function returns NULL rather than a platform-dependent path for the executable. `private_shlibdir` then falls back to the installed layout relative to `Sys.BINDIR`. Assisted-by: Claude Code (Opus 5.5) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Author
Parents
Loading