Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stable_abi/compiled.{c,rs} on non-CRuby #424

Open
eregon opened this issue Sep 23, 2024 · 0 comments
Open

Use stable_abi/compiled.{c,rs} on non-CRuby #424

eregon opened this issue Sep 23, 2024 · 0 comments

Comments

@eregon
Copy link

eregon commented Sep 23, 2024

Hello,

I'm coming from oracle/truffleruby#3396, in short we're trying to make Rust extensions work on TruffleRuby.
There were some minor fixes in RbConfig, etc which have been fixed in truffleruby-dev.

The remaining errors are in oracle/truffleruby#3396 (comment)
So for example:

error[E0609]: no field `flags` on type `uncategorized::RBasic`
  --> /home/eregon/.rubies/truffleruby-dev/lib/gems/gems/commonmarker-1.1.5/ext/commonmarker/.rb-sys/stable/cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.99/src/stable_api/ruby_3_2.rs:19:35
   |
19 |         let flags = rstring.basic.flags;
   |                                   ^^^^^ unknown field

This is because TruffleRuby doesn't and cannot expose flags on struct RBasic.
And anyway we can see the code in ruby_3_2.rs is highly CRuby-specific:

let flags = rstring.basic.flags;
let is_heap = (flags & crate::ruby_rstring_flags::RSTRING_NOEMBED as VALUE) != 0;
if !is_heap {
rstring.as_.embed.len as _
} else {
rstring.as_.heap.len
}

So such code in this file should only be used on CRuby, and on no other Ruby implementation.
And https://github.com/oxidize-rb/rb-sys/blob/991df6de21d244631e1b889070a8e4136f4220fe/crates/rb-sys/src/stable_api/compiled.c should be used instead.
A good way to test if it's CRuby is RUBY_ENGINE == "ruby".

Could you fix this issue?

Related: #229 cc @ianks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant