oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

cld: No enum constant com.oracle.truffle.nfi.spi.types.NativeSimpleType.STRUCT_BY_VALUE #2069

Open deepj opened 4 years ago

deepj commented 4 years ago
truffleruby 20.3.0-dev-a1514d37, like ruby 2.6.6, GraalVM CE Native [x86_64-darwin]

To reproduce:

gem install cld
ruby -rcld -e 'puts CLD.detect_language("The rose is red, the violet's blue")'

Error:

~/.rubies/truffleruby-dev/lib/truffle/truffle/ffi_backend/function.rb:50:in `initialize': No enum constant com.oracle.truffle.nfi.spi.types.NativeSimpleType.STRUCT_BY_VALUE (ArgumentError)
    from ~/.gem/truffleruby/2.6.6/gems/ffi-1.13.1/lib/ffi/library.rb:265:in `new'
    from ~/.gem/truffleruby/2.6.6/gems/ffi-1.13.1/lib/ffi/library.rb:265:in `block in attach_function'
    from ~/.gem/truffleruby/2.6.6/gems/ffi-1.13.1/lib/ffi/library.rb:252:in `each'
    from ~/.gem/truffleruby/2.6.6/gems/ffi-1.13.1/lib/ffi/library.rb:252:in `attach_function'
    from ~/.gem/truffleruby/2.6.6/gems/cld-0.8.0/lib/cld.rb:20:in `<module:CLD>'
    from ~/.gem/truffleruby/2.6.6/gems/cld-0.8.0/lib/cld.rb:4:in `<top (required)>'
    from <internal:core> core/kernel.rb:234:in `gem_original_require'
    from ~/.rubies/truffleruby-dev/lib/mri/rubygems/core_ext/kernel_require.rb:130:in `require'
    from <internal:core> core/unbound_method.rb:20:in `call'
    from <internal:core> core/unbound_method.rb:20:in `bind_call'
    from <internal:core> core/kernel.rb:267:in `require'
eregon commented 4 years ago

Thanks for the report.

I think this is the same source issue as in https://github.com/oracle/truffleruby/issues/1827#issuecomment-670532854 that is, Truffle NFI does not support passing struct-by-value yet (internal issue: GR-13304). And so our FFI implementation which uses Truffle NFI cannot yet either.

The usage of struct-by-value is in: https://github.com/jtoy/cld/blob/bd4e4a19691c642c52fba8589dada50e3f1365e7/lib/cld.rb#L20

alextwoods commented 4 years ago

I'm also running into this - I'm developing a new gem based on FFI and wanted to ensure compatibility with Truffle Ruby, but all of my CI tests started failing when using Struct.by_value.