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

Errors while installing gem in raspberry pi (armv6) #23

Closed
vasilakisfil opened this issue Mar 22, 2014 · 32 comments
Closed

Errors while installing gem in raspberry pi (armv6) #23

vasilakisfil opened this issue Mar 22, 2014 · 32 comments

Comments

@vasilakisfil
Copy link

I get these errors as soon as bundler tries to install the scrypt gem (version 1.2.0) in my raspberry pi:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.1.1/bin/ruby -rubygems /usr/local/rvm/gems/ruby-2.1.1/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/usr/local/rvm/gems/ruby-2.1.1/extensions/armv6l-linux/2.1.0/scrypt-1.2.0 RUBYLIBDIR=/usr/local/rvm/gems/ruby-2.1.1/extensions/armv6l-linux/2.1.0/scrypt-1.2.0
mkdir -p arm-linux
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -fPIC  -o arm-linux/crypto_scrypt-sse.o -c ./crypto_scrypt-sse.c
cc1: error: unrecognized command line option '-msse'
cc1: error: unrecognized command line option '-msse2'
rake aborted!
Command failed with status (1): [gcc -fexceptions -O -fno-omit-frame-pointe...]
/usr/local/rvm/gems/ruby-2.1.1/gems/ffi-compiler-0.1.3/lib/ffi-compiler/compile_task.rb:114:in `block (2 levels) in define_task!'
Tasks: TOP => default => arm-linux/libscrypt_ext.so => arm-linux/crypto_scrypt-sse.o
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.1.1/gems/scrypt-1.2.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.1.1/extensions/armv6l-linux/2.1.0/scrypt-1.2.0/gem_make.out
An error occurred while installing scrypt (1.2.0), and Bundler cannot continue.
Make sure that `gem install scrypt -v '1.2.0'` succeeds before bundling.

Any ideas?

@vasilakisfil
Copy link
Author

Cloning the repository and deleting the -msse and -msse2 options from ext/scrypt/Rakefile worked.

@vasilakisfil
Copy link
Author

Actually it didn't worked because when I am trying to launch my application using thin I get these errors:

Using rack adapter
/usr/local/rvm/gems/ruby-2.1.1/gems/ffi-compiler-0.1.3/lib/ffi-compiler/loader.rb:21:in `find': cannot find 'scrypt_ext' library (LoadError)
    from /var/www/scrypt/lib/scrypt/scrypt_ext.rb:7:in `<module:Ext>'
    from /var/www/scrypt/lib/scrypt/scrypt_ext.rb:5:in `<module:SCrypt>'
    from /var/www/scrypt/lib/scrypt/scrypt_ext.rb:4:in `<top (required)>'
    from /var/www/scrypt/lib/scrypt.rb:3:in `require'
    from /var/www/scrypt/lib/scrypt.rb:3:in `<top (required)>'
    from /var/www/my-twitter/my_app.rb:6:in `require'
    from /var/www/my-twitter/my_app.rb:6:in `<top (required)>'
    from /var/www/my-twitter/config.ru:1:in `require'
    from /var/www/my-twitter/config.ru:1:in `block in <main>'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /var/www/my-twitter/config.ru:1:in `new'
    from /var/www/my-twitter/config.ru:1:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/rack/adapter/loader.rb:33:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/rack/adapter/loader.rb:33:in `load'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/rack/adapter/loader.rb:42:in `for'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/thin/controllers/controller.rb:170:in `load_adapter'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/thin/controllers/controller.rb:74:in `start'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/thin/runner.rb:204:in `run_command'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/lib/thin/runner.rb:156:in `run!'
    from /usr/local/rvm/gems/ruby-2.1.1/gems/thin-1.6.0/bin/thin:6:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
    from /usr/local/rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'

So any help will be appreciated :)

@stakach
Copy link
Collaborator

stakach commented Mar 23, 2014

The issue is the SSE processor extensions that are specific to x86 CPUs.
There is a folder called alt implementation in the ext folder.

If you use those files the extension should compile. I might look into ensuring those files are used on non-x86 platforms.

@stakach
Copy link
Collaborator

stakach commented Mar 23, 2014

In fact I am not sure if I should be replacing crypto_scrypt-sse.c with crypto_scrypt-nosse.c or crypto_scrypt-ref.c

@vasilakisfil would you be able to check if either of those alt implementations work for you? I assume crypto_scrypt-ref.c is the correct file. I don't have an arm system to play with.

Then I'll update the library to copy in the correct file for each platform before compiling.

@pbhogan any ideas?

@johanns
Copy link
Collaborator

johanns commented Mar 24, 2014

@stakach I have a Raspberry PI, and will check to see which works later this evening (-nosse.c vs -ref.c).

@vasilakisfil
Copy link
Author

Deleting the crypto_scrypt-sse.c and adding to the folder the nosse version seems to work. 2 tests fail though:

 1) SCrypt test vectors should match results of SCrypt function
     Failure/Error: SCrypt::Engine.scrypt('pleaseletmein', 'SodiumChloride', 1048576, 8, 1, 64).unpack('H*').first.should eq('2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4')
     RuntimeError:
       scrypt error -1


  2) SCrypt test vectors should match equivalent results sent through hash_secret() function
     Failure/Error: SCrypt::Engine.hash_secret('pleaseletmein', '100000$8$1$536f6469756d43686c6f72696465', 64).should match(/\$2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4$/)
     RuntimeError:
       scrypt error -1

@stakach
Copy link
Collaborator

stakach commented Mar 24, 2014

I have a feeling the ref version will not fail. From memory it deals with little and big edian platforms.

@vasilakisfil
Copy link
Author

Again the same tests fail:

  1) SCrypt test vectors should match results of SCrypt function
     Failure/Error: SCrypt::Engine.scrypt('pleaseletmein', 'SodiumChloride', 1048576, 8, 1, 64).unpack('H*').first.should eq('2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4')
     RuntimeError:
       scrypt error -1

  2) SCrypt test vectors should match equivalent results sent through hash_secret() function
     Failure/Error: SCrypt::Engine.hash_secret('pleaseletmein', '100000$8$1$536f6469756d43686c6f72696465', 64).should match(/\$2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4$/)
     RuntimeError:
       scrypt error -1

@stakach
Copy link
Collaborator

stakach commented Apr 4, 2014

@vasilakisfil and @johanns would either of you be able to see if you can find a solution for arm processors? Might be solved by updating the scrypt implementation - http://www.tarsnap.com/news.html mentions adding support for ARM OABI

@johanns
Copy link
Collaborator

johanns commented Apr 4, 2014

@stakach I'll look into it (although, it may not be till tomorrow evening).

@skull-squadron
Copy link

👍

@schuppeste
Copy link

need Tutorial to compile Scrypt/Scrypt_ext for ARM.. Its a little bit tricky for me.

@skull-squadron
Copy link

(Ping) Have the C sources been updated yet?

@stakach
Copy link
Collaborator

stakach commented Jan 11, 2015

No.. If someone can compile the original sources on ARM I'm happy to rewrite the build script to detect the platform and build appropriately

@skull-squadron
Copy link

I don't have a Raspberry Pi, but maybe someone else does.

What would be the necessary details they would need to post? Configure triple, preprocessor defines (platform detection), etc.?

@stakach
Copy link
Collaborator

stakach commented Jan 15, 2015

Well scrypt should build on ARM when using one of the alternative implementations
https://github.com/pbhogan/scrypt/tree/master/ext/alt-impl

Building the original implementation on ARM might be insightful too http://www.tarsnap.com/scrypt/scrypt-1.1.6.tgz

@J-F-M
Copy link

J-F-M commented May 14, 2015

Would really love some help installing the gem onto a ARM machine...

I can build the gem using either crypto_scrypt-nosse.c or crypto_scrypt-ref.c, but rails throws an exception (cannot find 'scrypt_ext' library).

@jywarren
Copy link

Hi, all - trying to get scrypt running in an ARM (chromebook) environment, and ran into this. Has anyone made progress on it? Thanks!

cc1: error: unrecognized command line option '-msse'
cc1: error: unrecognized command line option '-msse2'

@daxtens
Copy link

daxtens commented Feb 26, 2016

I've hit this on POWER too (ppc64le). Any progress on a generic solution?

@stakach
Copy link
Collaborator

stakach commented Feb 26, 2016

I wrote a build script that detects ARM and SSE support, that then selects alternative implementations to compile etc however I never successfully compiled any of the implementations on ARM.

If anyone can give me cflags / ldflags or build script that will work on ARM I can make it happen.

@stakach
Copy link
Collaborator

stakach commented Feb 26, 2016

Same with power arch too

@repagh
Copy link
Contributor

repagh commented Jun 26, 2016

The tests likely fail on raspberry pi because of the memory use; With 1048576 as "N", a malloc of 128_r_N+63 is made, r is 8, and in total this is requesting a G of memory.

I grabbed the updated code from the Tarsnip git, merged that in repagh/scrypt. The tarsnip code can detects & selects between different implementations. This passes the tests except for large N tests, which I commented out.

I am new at ruby & gemfile stuff, I hope you can test from my git version.

@stakach
Copy link
Collaborator

stakach commented Jun 26, 2016

I'll take a look now

@stakach
Copy link
Collaborator

stakach commented Jun 26, 2016

Anyone who has a ARM PC - could you please confirm scrypt now works on the platform?

Use the following to install:
gem install scrypt -P HighSecurity

@petter0007
Copy link

Tried installing, but got the following error:

root@raspberrypi:/home/pi# gem install scrypt -P HighSecurity
Fetching: scrypt-3.0.0.gem (100%)
ERROR:  While executing gem ... (Gem::Security::Exception)
    root cert /CN=steve/DC=advancedcontrol/DC=com/DC=au is not trusted

@stakach
Copy link
Collaborator

stakach commented Jul 4, 2016

Dang. Could you try it without HighSecurity?

gem install scrypt

@jywarren
Copy link

jywarren commented Jul 5, 2016

I just got v3 to install on an ARMv7 Chromebook in ubuntu trusty in a crouton environment. Nice! That had been a long-standing issue for us, thanks!

~$ gem install scrypt
Fetching: scrypt-3.0.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed scrypt-3.0.0
Parsing documentation for scrypt-3.0.0
Installing ri documentation for scrypt-3.0.0
Done installing documentation for scrypt after 0 seconds
1 gem installed

@Shelvak
Copy link

Shelvak commented Jul 7, 2016

I have the same problem with Archlinux in a Rpi2 - ARMv7 . But I can't upgrade to scrypt3, I have an old dependency :( (authlogic--)

@daxtens
Copy link

daxtens commented Jul 7, 2016

Works on Power too 💯

@stakach
Copy link
Collaborator

stakach commented Jul 7, 2016

Good to hear! Closing this issue for now. Feel free to re-open if v3.0.1 causes any issues ;)

@stakach stakach closed this as completed Jul 7, 2016
@alexmkio
Copy link

So, is there no solution for people like me and @Shelvak who have a dependency on an old version (2.0.2)? Can you back port the changes to make those versions compile on ARM?

@stakach
Copy link
Collaborator

stakach commented Aug 15, 2016

There is no functional difference between v2 and v3 except that it runs on ARM.
Should be a drop in replacement for projects with old dependencies if those dependencies are updated.

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