Skip to content

Commit 58d5aba

Browse files
staticfloatlazarusA
authored andcommitted
Add lbt_forwarded_funcs() to debug LBT forwarding issues (JuliaLang#55302)
It can be very helpful, when struggling with LBT forwarding, to see what functions were actually forwarded to a new library. This utility function makes it easy to query which functions are forwarded to that library.
1 parent dab955e commit 58d5aba

File tree

1 file changed

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

1 file changed

+19
-0
lines changed

Diff for: stdlib/LinearAlgebra/src/lbt.jl

+19
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,25 @@ function lbt_find_backing_library(symbol_name, interface::Symbol;
284284
end
285285

286286

287+
"""
288+
lbt_forwarded_funcs(config::LBTConfig, lib::LBTLibraryInfo)
289+
290+
Given a backing library `lib`, return the list of all functions that are
291+
forwarded to that library, as a vector of `String`s.
292+
"""
293+
function lbt_forwarded_funcs(config::LBTConfig, lib::LBTLibraryInfo)
294+
forwarded_funcs = String[]
295+
for (symbol_idx, symbol) in enumerate(config.exported_symbols)
296+
forward_byte_offset = div(symbol_idx - 1, 8)
297+
forward_byte_mask = 1 << mod(symbol_idx - 1, 8)
298+
if lib.active_forwards[forward_byte_offset+1] & forward_byte_mask != 0x00
299+
push!(forwarded_funcs, symbol)
300+
end
301+
end
302+
return forwarded_funcs
303+
end
304+
305+
287306
## NOTE: Manually setting forwards is referred to as the 'footgun API'. It allows truly
288307
## bizarre and complex setups to be created. If you run into strange errors while using
289308
## it, the first thing you should ask yourself is whether you've set things up properly.

0 commit comments

Comments
 (0)