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: https://rubygems.org/gems/libspotify — 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 (http://www.raspberrypi.org/), 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 2 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. 3 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 4 Posted by Eric Hodel on 19 Feb, 2013 08:54 PM

    Eric Hodel's Avatar

    gem which rbconfig

  4. 5 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.

  5. Support Staff 6 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.

  6. 7 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!

  7. Support Staff 8 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":

    http://tenderlovemaking.com/2009/05/07/fat-binary-gems-make-the-roc...

    Good luck

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

    Eric Hodel's Avatar

     

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

  10. Support Staff 10 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

Generic

? 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