From a62c25e6cebbe4cd0165e55157d783d0ca03a271 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 2 Dec 2026 18:03:55 +0100 Subject: [PATCH] Don't extend LD_LIBRARY_PATH with the NEO directory in __init__ The variable has no effect on the running process, since glibc reads it at startup, and the in-process driver discovery it was meant for is now handled by dlopen'ing NEO by full path. Child processes did inherit it, though. With NEO_jll pointed at a system driver in e.g. /usr/lib64, that directory took precedence over every JLL's RUNPATH in precompile workers and Pkg.test, so bundled libraries such as SPIRV_Tools_jll resolved their dependencies against older system copies and failed to load. Children that need NEO load oneAPI.jl and perform the same dlopen themselves. Fixes #778. --- src/oneAPI.jl | 18 ++++++------------ test/level-zero.jl | 5 +++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/oneAPI.jl b/src/oneAPI.jl index 52e08d63..617cc5c1 100644 --- a/src/oneAPI.jl +++ b/src/oneAPI.jl @@ -211,19 +211,13 @@ function __init__() # resident in this process before libsycl loads: a later # dlopen("libze_intel_gpu.so.1") then resolves to this module by soname without # needing a search path. Required when no system NEO is installed. + # + # Don't extend LD_LIBRARY_PATH instead: glibc reads it only at startup, and + # child processes (precompile workers, `Pkg.test`) would inherit it. With a + # system NEO in e.g. /usr/lib, that directory then overrides every JLL's + # RUNPATH there (#778). A child that needs NEO loads oneAPI.jl, whose + # __init__ performs this dlopen itself. Libdl.dlopen(oneL0.NEO_jll.libze_intel_gpu; throw_error = false) - - # Extend LD_LIBRARY_PATH with the NEO directory as well. NOTE: this does NOT - # affect the running process's own dlopen search — glibc captures - # LD_LIBRARY_PATH once at startup — so it serves only *child* processes (e.g. - # the multi-worker test suite) that inherit the environment and do their own - # path-based driver discovery. In-process discovery is handled by the dlopen - # above (and by ZE_ENABLE_ALT_DRIVERS, set in oneL0's __init__). - neo_libdir = dirname(oneL0.NEO_jll.libze_intel_gpu) - ld = get(ENV, "LD_LIBRARY_PATH", "") - if !occursin(neo_libdir, ld) - ENV["LD_LIBRARY_PATH"] = isempty(ld) ? neo_libdir : "$neo_libdir:$ld" - end end end diff --git a/test/level-zero.jl b/test/level-zero.jl index ac1dd0ac..cceaadb2 100644 --- a/test/level-zero.jl +++ b/test/level-zero.jl @@ -4,6 +4,11 @@ using oneAPI.oneL0 # otherwise we risk loading multiple drivers, e.g., if a system driver is available. if oneL0.NEO_jll.is_available() @test endswith(oneL0.NEO_jll.libze_intel_gpu, ".1") + + # child processes inherit LD_LIBRARY_PATH, where a system driver's directory would + # override the RUNPATH of every JLL (#778) + neo_libdir = dirname(oneL0.NEO_jll.libze_intel_gpu) + @test !in(neo_libdir, split(get(ENV, "LD_LIBRARY_PATH", ""), ':')) end