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

CargoBuilder JRuby support #285

Open
uvlad7 opened this issue Dec 6, 2023 · 3 comments
Open

CargoBuilder JRuby support #285

uvlad7 opened this issue Dec 6, 2023 · 3 comments

Comments

@uvlad7
Copy link

uvlad7 commented Dec 6, 2023

rb_sys/mkmf can be used to compile not only rb_sys-based gems, but any gem that contains Rust code. I've found it useful to compile rust code used in JRuby through JNI, but it can also be used to compile Rust libraries called through FFI in both MRI and JRuby. However, I needed to make a small patch to make it compile on JRuby. So, the question is: would you accept a PR with these changes? It actually can require more patches as I only tested them on Ubuntu, dynamically linked Ruby 3.2.

@ianks
Copy link
Collaborator

ianks commented Dec 10, 2023

I’m not opposed to the idea, the patch is hard to review though. If you can make a prototype PR with the code that would be great! If that looks solid, we can polish it up to ship.

@uvlad7
Copy link
Author

uvlad7 commented Dec 15, 2023

I need your help, I updated oxi-test gem to work with jruby for rb-sys CI tests, but env preparation fails and I don't understand why.

UPD: Just cargo-binstall action doesn't work on jruby

I tried to debug:

    File.write 'tmp1', response.body.bytes.inspect
    File.write 'tmp2', pipe_command("#{RbConfig.ruby} -e 'puts STDIN.read.bytes.inspect'", stdin: response.body)

and appears it can't handle long stdins:

3.0.2 :002 > arr1 = eval(File.read 'tmp1'); nil
 => nil 
3.0.2 :003 > arr2 = eval(File.read 'tmp2'); nil
3.0.2 :006 > arr1.size
 => 6290974 
3.0.2 :007 > arr2.size
 => 98304
3.0.2 :010 > arr1[0...arr2.size] == arr2
 => true 

And this problem reproduces only from time to time

@uvlad7
Copy link
Author

uvlad7 commented Dec 21, 2023

So, it works on ubuntu and macos, but I'm not able to make it work on windows

Here is a Makefile generated on Jruby, and here - on MRI. The first one fails.
@ianks, can you take a look? I don't have Win installed, so it's painful to debug.

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