[ruby/irb] Respect DLEXT to force-load debug.so

(https://github.com/ruby/irb/pull/481)

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit is contained in:
Takashi Kokubun 2022-12-20 09:05:58 -08:00
parent 80e56d1438
commit cf0b413ef8

View File

@ -102,13 +102,14 @@ module IRB
return false unless debug_gem
# Discover debug/debug.so under extensions for Ruby 3.2+
debug_so = Gem.paths.path.flat_map do |path|
Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}/debug/debug.so")
ext_name = "/debug/debug.#{RbConfig::CONFIG['DLEXT']}"
ext_path = Gem.paths.path.flat_map do |path|
Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}#{ext_name}")
end.first
# Attempt to forcibly load the bundled gem
if debug_so
$LOAD_PATH << debug_so.delete_suffix('/debug/debug.so')
if ext_path
$LOAD_PATH << ext_path.delete_suffix(ext_name)
end
$LOAD_PATH << "#{debug_gem}/lib"
begin