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

memcached uses lower-case class names #2739

Closed nirvdrum closed 2 years ago

nirvdrum commented 2 years ago

The last released version of memcached (1.8.0, released on 07-May-2014) defines a class with a lower-case name in a native extension. rb_define_class allows this, but TruffleRuby's implementation does not because it shares code with the Ruby side of things and performs name validation. This results in the gem being unable to load:

NameError:
  wrong constant name swig_runtime_data
# <internal:core> core/module.rb:103:in `const_defined?'
# /Users/nirvdrum/dev/workspaces/truffleruby-ws/graal/sdk/mxbuild/darwin-aarch64/GRAALVM_A33290E019_JAVA11/graalvm-a33290e019-java11-22.3.0-dev/Contents/Home/languages/ruby/lib/truffle/truffle/cext.rb:1176:in `rb_define_class_under'
# define.c:27:in `rb_define_class'
# /Users/nirvdrum/dev/workspaces/truffleruby-ws/graal/sdk/mxbuild/darwin-aarch64/GRAALVM_A33290E019_JAVA11/graalvm-a33290e019-java11-22.3.0-dev/Contents/Home/languages/ruby/lib/gems/gems/memcached-1.8.0/ext/rlibmemcached_wrap.c:1737:in `Init_rlibmemcached'
# <internal:core> core/kernel.rb:226:in `gem_original_require'

The problematic code no longer exists in the memcached gem, but there hasn't been a release in over seven years. Even if we can convince the authors to release one, its master branch is set to 2.0.0.alpha, which would preclude it from an automatic update for most dependency graphs as it's a major version bump.

eregon commented 2 years ago

rb_define_module_under already supports that, see https://github.com/oracle/truffleruby/blob/7cc607338c2d83cb834f3f5afe0016af6e523f08/lib/truffle/stringio.rb#L31. So it should be fairly easy to support it for rb_define_class too. PR welcome.

nirvdrum commented 2 years ago

I meant to assign this to myself. I fixed it just recently as part of a larger PR to run the memcached gem.

nirvdrum commented 2 years ago

Fixed by cb44f1b.