Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/oneAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions test/level-zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading