How to target armhf vs. armel (e.g. different OSs on raspberry pi)?

Kim Burgestrand's Avatar

Kim Burgestrand

19 Feb, 2013 06:04 PM

I need to target armel/armhf (soft float vs hard floats) on the raspberry pi in one of my gems. My gem contains a binary which is sensitive to hard vs. soft floats. ruby -e 'p Gem::Platform.local.to_s' reports armv6l-linux on both hard float and soft float OS. How can I make two gems, one for each of the two platform differences? How can I figure out which platform to target through the gem platform option?

If there’s no way, do you have any ideas on how I might approach the problem in another way? I currently fall back to system binary if no platform-specific gem exists, but would really like to have the ease-of-installation that the binary-supplying gem brings.

Some more details:

I have a gem which includes a dynamic library. This library is different per platform (e.g. linux vs mac vs windows), which I currently target specifically. libspotify is the gem in question: — for non-supported platforms I simply fall back to a no-platform variant, which does not include the binary, and grabs it from system-installed locations (if available).

Now, there is the raspberry pi (, which in essence is just a tiny computer. libspotify, the binary I supply through my gem, has different binaries depending on if your raspberry pi OS is using hard floats (armhf) or soft floats (armel). However, I’m not sure if rubygems support targeting these two separately, or how I can find it out. This last thing is what I need help with.

  1. Support Staff 1 Posted by Eric Hodel on 19 Feb, 2013 08:49 PM

    Eric Hodel's Avatar

    Can you attach the rbconfig.rb for each platform?

  2. 2 Posted by Kim Burgestrand on 19 Feb, 2013 08:51 PM

    Kim Burgestrand's Avatar

    Will do. How do I find it?

  3. Support Staff 3 Posted by Eric Hodel on 19 Feb, 2013 08:54 PM

    Eric Hodel's Avatar

    gem which rbconfig

  4. 4 Posted by Kim Burgestrand on 19 Feb, 2013 09:03 PM

    Kim Burgestrand's Avatar

    I’ll upload the first rbconfig.rb in an hour or two after ruby has finished compiling. I’ll upload the next one around ten hours from now, as I’ll be compiling the same ruby on the other OS again during the night.

  5. 5 Posted by Kim Burgestrand on 19 Feb, 2013 10:11 PM

    Kim Burgestrand's Avatar

    I need to compile one ruby on the current OS, reinstall the other OS, and compile ruby on that OS. Will do it during the night/after work so I’ll have them up within 24 hours or so.

  6. 6 Posted by Kim Burgestrand on 21 Feb, 2013 06:54 AM

    Kim Burgestrand's Avatar

    Here they are.

    Unfortunately, it looks like they are identical on the two platforms. I’ve been poking around, it appears just knowing which one you are on, even when you have full access to the system, is not straight forward.

    If it’s not possible for rubygems to see the difference, I could probably solve it with some runtime configuration option or so.

  7. 7 Posted by Kim Burgestrand on 22 Feb, 2013 06:54 AM

    Kim Burgestrand's Avatar

    Appears my comments (all five) are getting caught in a moderation filter of sorts.

  8. 8 Posted by Kim Burgestrand on 22 Feb, 2013 06:55 AM

    Kim Burgestrand's Avatar

    As you can see the files are identical. Does this mean rubygems can’t separate the two platforms? I could probably do a sensible default and allow the user to override the option, in case they are on a hard float platform.

  9. Support Staff 9 Posted by Eric Hodel on 26 Feb, 2013 12:49 AM

    Eric Hodel's Avatar

    There is no difference between these two files so there is no way for RubyGems to target one or the other.

    Ultimately the values in rbconfig.rb come from autoconf. I'm unsure of who to contact to figure out if autoconf knows there is a difference.

    If you have some other way of detecting the hardware you're running on you can use extconf.rb to install the correct version along with a platform targeted at arm-linux-gnueabi.

  10. 10 Posted by Kim Burgestrand on 27 Feb, 2013 09:14 PM

    Kim Burgestrand's Avatar

    Looks like I have to fall back on some runtime check. Thanks Eric!

  11. Support Staff 11 Posted by Eric Hodel on 27 Feb, 2013 09:18 PM

    Eric Hodel's Avatar

    You can also package both versions of the shared library in your gem and require the appropriate one at runtime. This technique is known as "fat binary gems":

    Good luck

  12. Support Staff 12 Posted by Eric Hodel on 27 Feb, 2013 09:18 PM

    Eric Hodel's Avatar


  13. Eric Hodel closed this discussion on 27 Feb, 2013 09:18 PM.

  14. Support Staff 13 Posted by Eric Hodel on 27 Feb, 2013 09:18 PM

    Eric Hodel's Avatar


Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac