ruby / fiddle

A libffi wrapper for Ruby.
BSD 2-Clause "Simplified" License
163 stars 36 forks source link

Import TruffleRuby implementation #148

Closed kou closed 1 month ago

kou commented 2 months ago

Fix GH-145

lib/fiddle/truffleruby.rb is based on https://github.com/oracle/truffleruby/blob/master/lib/truffle/truffle/fiddle_backend.rb .

Here are changes for it:

Some features are still "not implemented". So there are some "omit"s for TruffleRuby in tests.

kou commented 2 months ago

This is based on GH-147. So we should not merge this before GH-147.

eregon commented 2 months ago

I changed the target branch so this PR shows the relevant diff.

kou commented 2 months ago

I've added truflleruby-20 and truffleruby-21 because:

ruby/setup-ruby don't provide them for macos-14 and ubuntu-24.04:

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952238981?pr=148#step:3:17

Error: Error: Unavailable version 20.3.0 for truffleruby on macos-14

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952239103?pr=148#step:3:17

Error: Error: Unavailable version 21.3.0 for truffleruby on macos-14

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952240601?pr=148#step:3:14

Error: Error: Unavailable version 20.3.0 for truffleruby on ubuntu-24.04

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952240753?pr=148#step:3:14

Error: Error: Unavailable version 21.3.0 for truffleruby on ubuntu-24.04

truffleruby-20 on macos-12 doesn't work because it doesn't work with recent Bundler:

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952235259?pr=148#step:3:27

   Using latest Bundler for truffleruby-20.3.0 because the default Bundler gem is too old for that Ruby version
  Ruby 2.6-2.7 only works with Bundler 2.4
  /Users/runner/.rubies/truffleruby-20.3.0/bin/gem install bundler --force -v ~> 2.4.0

truffleruby-21 on macos-12 doesn't work because of internal Bundler error:

https://github.com/ruby/fiddle/actions/runs/11137969090/job/30952235963?pr=148#step:4:10

NameError: method `search_by_dependency' not defined in Bundler::Index

Should we really care about old TruffleRuby releases?

eregon commented 2 months ago

I've added truffleruby-20 and truffleruby-21 because:

The versions at https://www.graalvm.org/release-calendar/#previous-releases are very confusing unfortunately, as they use Java versions, while Truffle/TruffleRuby versions use the year. So truffleruby-20 and truffleruby-21 are ancient, from 2020 and 2021.

The current GraalVM LTS is GraalVM for JDK 21, which corresponds to TruffleRuby 23.1.0. So it might make sense to test that and/or 24.0 as well.

I think we should solve it for all existing TruffleRuby releases if possible and #146 is one way to do that. This PR is unlikely to work on older releases, and might not even work on the latest release, once we avoid depending on internal & changing APIs.

kou commented 1 month ago

We use #149 instead of this.