Skip to content

Commit 1a1270d

Browse files
Add missing exec paths to new Zstd_jll stdlib (#59198)
`Zstd_jll.zstd_path::String` is provided by the non-stdlib JLL, like for all executable products, so not having this is breaking, I believe. Also add a test to catch this for existing/new stdlibs.
1 parent 905a847 commit 1a1270d

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

stdlib/Zstd_jll/src/Zstd_jll.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const LIBPATH_list = String[]
1818
artifact_dir::String = ""
1919

2020
libzstd_path::String = ""
21+
zstd_path::String = ""
22+
zstdmt_path::String = ""
2123
const libzstd = LazyLibrary(
2224
if Sys.iswindows()
2325
BundledLazyLibraryPath("libzstd-1.dll")
@@ -79,8 +81,8 @@ function zstdmt(f::Function; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = tr
7981
f(zstdmt())
8082
end
8183
end
82-
zstd() = adjust_ENV(`$(joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstd_exe))`)
83-
zstdmt() = adjust_ENV(`$(joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstdmt_exe))`)
84+
zstd() = adjust_ENV(`$zstd_path`)
85+
zstdmt() = adjust_ENV(`$zstdmt_path`)
8486

8587
# Function to eagerly dlopen our library and thus resolve all dependencies
8688
function eager_mode()
@@ -94,6 +96,8 @@ is_available() = true
9496

9597
function __init__()
9698
global libzstd_path = string(libzstd.path)
99+
global zstd_path = joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstd_exe)
100+
global zstdmt_path = joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, zstdmt_exe)
97101
global artifact_dir = dirname(Sys.BINDIR)
98102
end
99103

test/stdlib_dependencies.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,47 @@ try
273273
end
274274
end
275275

276+
# Check that any JLL stdlib that defines executables also provides corresponding *_path variables
277+
@testset "Stdlib JLL executable path variables" begin
278+
for (_, (stdlib_name, _)) in Pkg.Types.stdlibs()
279+
if !endswith(stdlib_name, "_jll")
280+
continue
281+
end
282+
283+
# Import the stdlib, skip it if it's not available on this platform
284+
m = eval(Meta.parse("import $(stdlib_name); $(stdlib_name)"))
285+
if !Base.invokelatest(getproperty(m, :is_available))
286+
continue
287+
end
288+
289+
# Look for *_exe constants that indicate executable definitions
290+
exe_constants = Symbol[]
291+
for name in names(m, all=true)
292+
name_str = string(name)
293+
if endswith(name_str, "_exe") && isdefined(m, name)
294+
push!(exe_constants, name)
295+
end
296+
end
297+
298+
# For each *_exe constant, check if there's a corresponding *_path variable
299+
for exe_const in exe_constants
300+
exe_name_str = string(exe_const)
301+
# Convert from *_exe to *_path (e.g., zstd_exe -> zstd_path)
302+
expected_path_var = Symbol(replace(exe_name_str, "_exe" => "_path"))
303+
304+
@test isdefined(m, expected_path_var)
305+
306+
if !isdefined(m, expected_path_var)
307+
@warn("Missing path variable",
308+
jll = stdlib_name,
309+
exe_constant = exe_const,
310+
expected_path_var = expected_path_var
311+
)
312+
end
313+
end
314+
end
315+
end
316+
276317
finally
277318
if prev_env !== nothing
278319
Pkg.activate(prev_env)

0 commit comments

Comments
 (0)