Skip to content

Commit 16e62d6

Browse files
committed
[LinearAlgebra] Improve resilience to unknown libblastrampoline flags
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 dfb2fd9 commit 16e62d6

File tree

1 file changed

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

1 file changed

+18
-4
lines changed

stdlib/LinearAlgebra/src/lbt.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ 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+
$(esc(map))[-1]
22+
else
23+
$(esc(map))[$(esc(key))]
24+
end
25+
end
26+
end
27+
1628
const LBT_INTERFACE_LP64 = 32
1729
const LBT_INTERFACE_ILP64 = 64
1830
const LBT_INTERFACE_UNKNOWN = -1
@@ -35,10 +47,12 @@ const LBT_INV_F2C_MAP = Dict(v => k for (k, v) in LBT_F2C_MAP)
3547

3648
const LBT_COMPLEX_RETSTYLE_NORMAL = 0
3749
const LBT_COMPLEX_RETSTYLE_ARGUMENT = 1
50+
const LBT_COMPLEX_RETSTYLE_FNDA = 2
3851
const LBT_COMPLEX_RETSTYLE_UNKNOWN = -1
3952
const LBT_COMPLEX_RETSTYLE_MAP = Dict(
4053
LBT_COMPLEX_RETSTYLE_NORMAL => :normal,
4154
LBT_COMPLEX_RETSTYLE_ARGUMENT => :argument,
55+
LBT_COMPLEX_RETSTYLE_FNDA => :float_normal_double_argument,
4256
LBT_COMPLEX_RETSTYLE_UNKNOWN => :unknown,
4357
)
4458
const LBT_INV_COMPLEX_RETSTYLE_MAP = Dict(v => k for (k, v) in LBT_COMPLEX_RETSTYLE_MAP)
@@ -69,10 +83,10 @@ struct LBTLibraryInfo
6983
lib_info.handle,
7084
unsafe_string(lib_info.suffix),
7185
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],
86+
@get_warn(LBT_INTERFACE_MAP, lib_info.interface),
87+
@get_warn(LBT_COMPLEX_RETSTYLE_MAP, lib_info.complex_retstyle),
88+
@get_warn(LBT_F2C_MAP, lib_info.f2c),
89+
@get_warn(LBT_CBLAS_MAP, lib_info.cblas),
7690
)
7791
end
7892
end

0 commit comments

Comments
 (0)