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

extend FFI::Library doesn't extend some methods into module #1529

Closed
deepj opened this issue Dec 16, 2018 · 11 comments

Comments

3 participants
@deepj
Copy link

commented Dec 16, 2018

There is no issue under MRI. After initializing the module, TestModule': undefined method 'callback' for TestModule:Module (NoMethodError) exception is occurred. The code below tries to call this method https://www.rubydoc.info/github/ffi/ffi/FFI/Library#callback-instance_method

require 'ffi'

module TestModule
  extend FFI::Library

  callback :g_log_func, [:string, :int, :string, :pointer], :void
end

TestModule

This is a small reproducible example of issue comes from https://github.com/libvips/ruby-vips/blob/428d5c106fb4a64521159c6b0c4f9391eea2eba6/lib/vips.rb#L36

Error:

ruby-ffi.rb:6:in `TestModule': undefined method `callback' for TestModule:Module (NoMethodError)
	from ruby-ffi.rb:3:in `<main>'
@deepj

This comment has been minimized.

Copy link
Author

commented Dec 16, 2018

It seems to be similar to #1524

@eregon

This comment has been minimized.

Copy link
Member

commented Dec 16, 2018

Our current implementation of FFI (using Truffle NFI) is not complete, so this means we did not implement that method yet.
It's an open question currently whether we can and how to reuse some of the upstream FFI code (we likely wouldn't want a second libffi copy, so using Truffle NFI would be better).

@deepj

This comment has been minimized.

Copy link
Author

commented Dec 16, 2018

@eregon Are you sure? Because in case of ruby-vips, the ffi is installed via Bundler, and ruby-vips specs are run via bundle exec rake spec. So I guess, the ffi is used.

@deepj

This comment has been minimized.

Copy link
Author

commented Dec 16, 2018

In fact I've seen more issues like undefined method 'callback' due to some issue in extending classes/modules in TruffleRuby.

@eregon

This comment has been minimized.

Copy link
Member

commented Dec 16, 2018

@deepj

This comment has been minimized.

Copy link
Author

commented Dec 16, 2018

@eregon I see, got it.

@eregon

This comment has been minimized.

Copy link
Member

commented Jan 22, 2019

This is also an issue for ethon (#1524) and sassc.
Related issue in upstream FFI: ffi/ffi#660
In short, I plan to do a pure-Ruby implementation of FFI using Truffle NFI as backend.

@deepj

This comment has been minimized.

Copy link
Author

commented Feb 12, 2019

@eregon @chrisseaton if there would be a chance to move FFI compability forward it could help to run more native gems on TruffleRuby. RC13/14?

@chrisseaton

This comment has been minimized.

Copy link
Member

commented Feb 12, 2019

I think we're unlikely to fix this one as fast as the other priority issues, I'm afraid. It's going to be a bit more work.

@chrisseaton

This comment has been minimized.

Copy link
Member

commented Apr 6, 2019

I'm going to remove the priority tag on this, as we aren't going to be able to solve it in the next month or so, which is what we're aiming at with priority issues now.

@chrisseaton chrisseaton removed the priority label Apr 6, 2019

@eregon

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

I fixed this in 59fb511 and added complete support for the FFI, with a pure-Ruby implementation using Truffle NFI.
It will be in the next release (1.0.0-rc16).
Thank you for the report.

@eregon eregon closed this Apr 18, 2019

@eregon eregon added the priority label Apr 18, 2019

@eregon eregon added this to the 1.0.0-rc16 milestone Apr 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.