From dc110c7244bd9bf119ddccfada6c0e98c02ed038 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 8 Apr 2025 11:21:37 +0200 Subject: [PATCH] `versioninfo`: simplify, improve type stability Change the `env_var_names` local from `Vector{Any}` to `Vector{Vector{String}}`. This should prevent some sysimage invalidation that happens on 64-bit Windows when running: ```julia struct I <: Integer end function Base.:(<<)(::I, ::Int) end ``` --- src/LinearAlgebra.jl | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/LinearAlgebra.jl b/src/LinearAlgebra.jl index ad98de00..8142779e 100644 --- a/src/LinearAlgebra.jl +++ b/src/LinearAlgebra.jl @@ -788,31 +788,22 @@ function versioninfo(io::IO=stdout) println(io, indent, "LinearAlgebra.BLAS.get_num_threads() = ", BLAS.get_num_threads()) println(io, "Relevant environment variables:") env_var_names = [ - "JULIA_NUM_THREADS", - "MKL_DYNAMIC", - "MKL_NUM_THREADS", + ["JULIA_NUM_THREADS"], + ["MKL_DYNAMIC"], + ["MKL_NUM_THREADS"], # OpenBLAS has a hierarchy of environment variables for setting the # number of threads, see # https://github.com/xianyi/OpenBLAS/blob/c43ec53bdd00d9423fc609d7b7ecb35e7bf41b85/README.md#setting-the-number-of-threads-using-environment-variables - ("OPENBLAS_NUM_THREADS", "GOTO_NUM_THREADS", "OMP_NUM_THREADS"), + ["OPENBLAS_NUM_THREADS", "GOTO_NUM_THREADS", "OMP_NUM_THREADS"], ] printed_at_least_one_env_var = false print_var(io, indent, name) = println(io, indent, name, " = ", ENV[name]) for name in env_var_names - if name isa Tuple - # If `name` is a Tuple, then find the first environment which is - # defined, and disregard the following ones. - for nm in name - if haskey(ENV, nm) - print_var(io, indent, nm) - printed_at_least_one_env_var = true - break - end - end - else - if haskey(ENV, name) - print_var(io, indent, name) + for nm in name + if haskey(ENV, nm) + print_var(io, indent, nm) printed_at_least_one_env_var = true + break end end end