Skip to content

Commit

Permalink
Only modified LOAD_PATH for RJIT with fiddle provided by bundled gems
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Feb 6, 2025
1 parent b4bfbca commit ec8e3e3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions rjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ def self.enable

if RubyVM::RJIT.enabled?
begin
fiddle_paths = %w[.bundle/gems/fiddle-*/lib .bundle/extensions/*/*/fiddle-*].map do |dir|
Dir.glob("#{File.expand_path("..", __FILE__)}/#{dir}").first
end.compact
$LOAD_PATH.unshift(*fiddle_paths) unless fiddle_paths.empty?

require 'fiddle'
require 'fiddle/import'
rescue LoadError
return # miniruby doesn't support RJIT
# Find fiddle from artifacts of bundled gems for make test-all
fiddle_paths = %w[.bundle/gems/fiddle-*/lib .bundle/extensions/*/*/fiddle-*].map do |dir|
Dir.glob("#{File.expand_path("..", __FILE__)}/#{dir}").first
end.compact
if fiddle_paths.empty?
return # miniruby doesn't support RJIT
else
$LOAD_PATH.unshift(*fiddle_paths)
retry
end
end

require 'ruby_vm/rjit/c_type'
Expand Down

0 comments on commit ec8e3e3

Please sign in to comment.