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

TruffleRuby support #189

Closed
mtortonesi opened this issue Aug 16, 2023 · 3 comments
Closed

TruffleRuby support #189

mtortonesi opened this issue Aug 16, 2023 · 3 comments

Comments

@mtortonesi
Copy link

In my quest of getting torch.rb to work, have been trying to build rice on top of TruffleRuby (truffleruby+graalvm-23.0.0 installed with rbenv+ruby-build on my M1 Mac) but I ran into some linking issues:

...
  "_ruby_init_loadpath", referenced from:
      fixture__Address_Registration_Guard__setup() in lto.o
      fixture_Array_setup() in lto.o
      fixture_Attribute_setup() in lto.o
      fixture__Builtin_Object__setup() in lto.o
      fixture_Class_setup() in lto.o
      fixture_Array_setup() (.263) in lto.o
      fixture__Data_Object__setup() in lto.o
      ...
  "_ruby_sysinit", referenced from:
      fixture__Address_Registration_Guard__setup() in lto.o
      fixture_Array_setup() in lto.o
      fixture_Attribute_setup() in lto.o
      fixture__Builtin_Object__setup() in lto.o
      fixture_Class_setup() in lto.o
      fixture_Array_setup() (.263) in lto.o
      fixture__Data_Object__setup() in lto.o
      ...
ld: symbol(s) not found for architecture arm64
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [unittest] Error 1
rake aborted!
Failed
/Users/mauro/code/test/truffleruby/rice/rakefile:12:in `block in run_command'
/Users/mauro/code/test/truffleruby/rice/rakefile:8:in `run_command'
/Users/mauro/code/test/truffleruby/rice/rakefile:33:in `block (3 levels) in <top (required)>'
<internal:core> core/dir.rb:321:in `chdir'
/Users/mauro/code/test/truffleruby/rice/rakefile:31:in `block (2 levels) in <top (required)>'
<internal:core> core/kernel.rb:381:in `load'
Tasks: TOP => build => /Users/mauro/code/test/truffleruby/

And that is even after I manually changed CMakeLists.txt to include header dirs and library files:

  target_include_directories (unittest PRIVATE "/Users/mauro/.rbenv/versions/truffleruby+graalvm-23.0.0/graalvm/Contents/Home/languages/ruby/lib/cext/include")
  target_include_directories (unittest PRIVATE "/Users/mauro/.rbenv/versions/truffleruby+graalvm-23.0.0/graalvm/Contents/Home/languages/llvm/include")
  target_link_libraries (unittest "/Users/mauro/.rbenv/versions/truffleruby+graalvm-23.0.0/graalvm/Contents/Home/languages/ruby/lib/cext/librubysignal.dylib")
  target_link_libraries (unittest "/Users/mauro/.rbenv/versions/truffleruby+graalvm-23.0.0/graalvm/Contents/Home/languages/ruby/lib/cext/libtruffleruby.dylib")
  target_link_libraries (unittest "/Users/mauro/.rbenv/versions/truffleruby+graalvm-23.0.0/graalvm/Contents/Home/languages/ruby/lib/cext/libtruffleposix.dylib")

I am rather lost at the moment. Do you have any ideas / suggestions on how to move on from here?

@jasonroelofs
Copy link
Collaborator

I would be rather surprised if this worked. Rice is pretty strongly linked to how Ruby itself is implemented, and makes at least one or two internal calls (e.g. rb_frame_method_id_and_class). So you would need to find an alternate to this method in the TruffleRuby C API, and even then I have no idea if it would work at all.

Or, to put it shortly, only MRI is supported.

@mtortonesi
Copy link
Author

I am wondering if I could add to truffleruby the internal calls that rice requires. I started looking into it, but got a compilation problem. I submitted an issue: oracle/truffleruby#3357. I will keep you posted.

@mtortonesi
Copy link
Author

mtortonesi commented Dec 27, 2023

FYI, I just submitted oracle/truffleruby#3363, that implements the rb_frame_method_id_and_class in Truffleruby. The patch seems to get rice, and in turn torch.rb, to work with Truffleruby.

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

2 participants