Skip to content

Commit 5044506

Browse files
authored
[LinearAlgebra] Improve resilience to unknown libblastrampoline flags (#54781)
When testing a new version of `libblastrampoline` that may have flags and values that we don't know about, raise a nice warning rather than a hard error.
1 parent 1505b07 commit 5044506

File tree

1 file changed

+19
-4
lines changed
  • stdlib/LinearAlgebra/src

1 file changed

+19
-4
lines changed

stdlib/LinearAlgebra/src/lbt.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ struct lbt_library_info_t
1313
f2c::Int32
1414
cblas::Int32
1515
end
16+
17+
macro get_warn(map, key)
18+
return quote
19+
if !haskey($(esc(map)), $(esc(key)))
20+
@warn(string("[LBT] Unknown key into ", $(string(map)), ": ", $(esc(key)), ", defaulting to :unknown"))
21+
# All the unknown values share a common value: `-1`
22+
$(esc(map))[$(esc(LBT_INTERFACE_UNKNOWN))]
23+
else
24+
$(esc(map))[$(esc(key))]
25+
end
26+
end
27+
end
28+
1629
const LBT_INTERFACE_LP64 = 32
1730
const LBT_INTERFACE_ILP64 = 64
1831
const LBT_INTERFACE_UNKNOWN = -1
@@ -35,10 +48,12 @@ const LBT_INV_F2C_MAP = Dict(v => k for (k, v) in LBT_F2C_MAP)
3548

3649
const LBT_COMPLEX_RETSTYLE_NORMAL = 0
3750
const LBT_COMPLEX_RETSTYLE_ARGUMENT = 1
51+
const LBT_COMPLEX_RETSTYLE_FNDA = 2
3852
const LBT_COMPLEX_RETSTYLE_UNKNOWN = -1
3953
const LBT_COMPLEX_RETSTYLE_MAP = Dict(
4054
LBT_COMPLEX_RETSTYLE_NORMAL => :normal,
4155
LBT_COMPLEX_RETSTYLE_ARGUMENT => :argument,
56+
LBT_COMPLEX_RETSTYLE_FNDA => :float_normal_double_argument,
4257
LBT_COMPLEX_RETSTYLE_UNKNOWN => :unknown,
4358
)
4459
const LBT_INV_COMPLEX_RETSTYLE_MAP = Dict(v => k for (k, v) in LBT_COMPLEX_RETSTYLE_MAP)
@@ -69,10 +84,10 @@ struct LBTLibraryInfo
6984
lib_info.handle,
7085
unsafe_string(lib_info.suffix),
7186
unsafe_wrap(Vector{UInt8}, lib_info.active_forwards, div(num_exported_symbols,8)+1),
72-
LBT_INTERFACE_MAP[lib_info.interface],
73-
LBT_COMPLEX_RETSTYLE_MAP[lib_info.complex_retstyle],
74-
LBT_F2C_MAP[lib_info.f2c],
75-
LBT_CBLAS_MAP[lib_info.cblas],
87+
@get_warn(LBT_INTERFACE_MAP, lib_info.interface),
88+
@get_warn(LBT_COMPLEX_RETSTYLE_MAP, lib_info.complex_retstyle),
89+
@get_warn(LBT_F2C_MAP, lib_info.f2c),
90+
@get_warn(LBT_CBLAS_MAP, lib_info.cblas),
7691
)
7792
end
7893
end

0 commit comments

Comments
 (0)