rbs icon indicating copy to clipboard operation
rbs copied to clipboard

[Epic] Pure C API

Open amomchilov opened this issue 11 months ago • 4 comments

Shopify is actively working on decoupling the RBS parser from its Ruby bindings, in order to expose a new pure C API.

This API will be more compatible (e.g. it can integrate into JRuby, Truffle, Sorbet, etc.), and will allow for multi-threaded RBS parsing (since it won't be blocked by Ruby's GVL).

PR list

This is still a work-in-progress, but this list will be updated to list all PRs that are ready to review, in the order that they should be merged.

  1. [x] #2098
  2. [x] #2102
  3. [x] #2128
  4. [x] #2131
  5. [x] #2132
  6. [ ] #2175
  7. [ ] #2221

CC @Morriar, @soutaro

amomchilov avatar Dec 06 '24 20:12 amomchilov

It looks like all the linked PRs have been merged. Is this done? Is there a way to get a prerelease gem pushed for testing, or JRuby added to CI?

headius avatar Apr 25 '25 14:04 headius

The main missing part would be https://github.com/ruby/rbs/pull/2398.

Morriar avatar Apr 25 '25 14:04 Morriar

@Morriar Ok thank you for that update!

In #2433 I noticed there are still a number of places that the ruby.h file and friends are required. I'm not sure if #2398 addresses all of those but any dependency on the header files from CRuby will likely need to be addressed in order for the library to build and run with JRuby.

I am standing by to help. The current dependencies prevent doing much on my end, though.

headius avatar Apr 25 '25 15:04 headius

With https://github.com/ruby/rbs/pull/2398, ruby.h isn't required anymore.

Here's how we use it from Sorbet (C++ implementation): https://github.com/sorbet/sorbet/blob/master/rbs/rbs_common.h#L5 and we don't need the Ruby VM.

Morriar avatar Apr 25 '25 16:04 Morriar