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

Unable to use jirb on ARMv7 processor #5362

Closed
abhi18av opened this Issue Oct 12, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@abhi18av
Copy link

abhi18av commented Oct 12, 2018

Hello jRuby team,

I'm trying to setup rails on my ARMv7 instance on Scaleaway C1 server but I am stuck with this error when I try to use jirb

root@pup:~# jirb
NotImplementedError: fstat unimplemented unsupported or native support failed to load; see http://wiki.jruby.org/Native-Libraries
  initialize at org/jruby/RubyIO.java:1036
        open at org/jruby/RubyIO.java:1177
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb/input-method.rb:141
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb/context.rb:70
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb.rb:410
       start at /usr/local/jruby/lib/ruby/stdlib/irb.rb:381
      <main> at /usr/local/jruby/bin/jirb:13

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
root@pup:~# jruby -v
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) Client VM 25.181-b13 on 1.8.0_181-b13 +jit [linux-arm]

  • Operating system and platform (e.g. uname -a)
root@pup:~# uname -a
Linux pup 4.9.93-mainline-rev1 #1 SMP Tue Apr 10 09:42:40 UTC 2018 armv7l armv7l armv7l GNU/Linux
@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 12, 2018

You may be able to run with -Xnative.enabled=false which will disably some native-level features but boot up better. We have another issue #5192 that also has issues booting on armv7 and hope to address that for 9.2.1.

@headius headius added this to the JRuby 9.2.1.0 milestone Oct 12, 2018

@abhi18av

This comment has been minimized.

Copy link
Author

abhi18av commented Oct 12, 2018

Mm hmm, I understand @headius , thanks 👍

Do you mean that I can use jirb like this

root@pup:~# jruby -Xnative.enabled=false -S jirb
NotImplementedError: fstat unimplemented unsupported or native support failed to load; see http://wiki.jruby.org/Native-Libraries
  initialize at org/jruby/RubyIO.java:1036
        open at org/jruby/RubyIO.java:1177
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb/input-method.rb:141
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb/context.rb:70
  initialize at /usr/local/jruby/lib/ruby/stdlib/irb.rb:410
       start at /usr/local/jruby/lib/ruby/stdlib/irb.rb:381
      <main> at /usr/local/jruby/bin/jirb:13
@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 12, 2018

Oh, I though that would work 😢

I'll try to get my raspi up and going this weekend and see if I can reproduce.

@abhi18av

This comment has been minimized.

Copy link
Author

abhi18av commented Oct 12, 2018

It's okay @headius

I do admire this wonderful effort on your part, jruby is the reason I love ruby :)

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 30, 2018

Finally got my Raspberry Pi 3 running...and I can reproduce.

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 30, 2018

I believe I have a lead on the problem.

There are a number of posts from 5-6 years ago about a transition that Debian made (and Rasbian with it) from soft floating point logic to hard floating point logic on ARM. Unfortunately softfp and hardfp must be compiled for and are not compatible with each other, so on a hardfp system as Rasbian is now, a softfp-compiled library won't be able to load.

That appears to be the case here. Here's the ELF EABI sections for the library we ship and for the java executable that comes with Rasbian:

pi@raspberrypi:~/jruby $ readelf -A jffi4052622518226348551.so 
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM9TDMI"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_optimization_goals: Aggressive Speed
pi@raspberrypi:~/jruby $ readelf -A `which java` 
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
  Tag_DIV_use: Not allowed

Given that hardfp is now the most common mode on all modern ARM systems, and our 32-bit ARM library has not been rebuilt since 2012, I'm thinking we should recompile it with hardfp.

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 30, 2018

Rebuilding the ARM binary on my pi3 appears to produce a binary with the proper EABI:

pi@raspberrypi:~/jffi $ readelf -A build/jni/libjffi-1.2.so 
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

And voila, it works in JRuby:

pi@raspberrypi:~/jruby $ jirb
irb(main):001:0> puts 'hello'
hello
=> nil
irb(main):002:0> 

So the remaining question is whether this is suitable to ship as our sole ARM32 binary, or whether we need to add in loading logic to support both soft and hardfp as done in Pi4J/pi4j#1.

@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 30, 2018

I have pushed an updated ARM binary in jnr/jffi#58. You can test it in JRuby by rebuilding both:

  1. Check out the PR branch from jnr/jffi#58
  2. mvn install from jffi dir
  3. Check out JRuby master
  4. Modify JRuby's root pom.rb to use 1.2.18-SNAPSHOT for jffi.version.
  5. mvn clean package from jruby dir

This should produce a JRuby distribution that works properly on hardfp ARM32.

I'm still trying to determine the risk of shipping a hardfp binary.

headius added a commit to headius/jruby that referenced this issue Oct 30, 2018

Update jffi to 1.2.18 for refreshed 32-bit ARM support.
This pulls in the latest jffi, which has a new 32-bit ARM binary
rebuilt for hard-float EABI that appears to be typical on modern
ARM Linux distributions.

Fixes jruby#5362.
Fixes jruby#5192.
@headius

This comment has been minimized.

Copy link
Member

headius commented Oct 30, 2018

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.