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

Compiling on ARM fails #25

Closed
seriousmumbo opened this issue Oct 9, 2014 · 12 comments
Closed

Compiling on ARM fails #25

seriousmumbo opened this issue Oct 9, 2014 · 12 comments

Comments

@seriousmumbo
Copy link

Libsodium fails to compile on ARM. I ran 'node-gyp configure' and 'node-gyp build'. I've copypasta'd the entire thing below, but I think the relevant part is this:

crypto_onetimeauth/poly1305/donna/portable-jane.h:674: unable to emulate 'TI'

Any ideas?

root@7el8ql:~/node-sodium# node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@0.10.10
gyp info using node@0.10.25 | linux | arm
gyp info spawn python
gyp info spawn args [ '/usr/share/node-gyp/gyp/gyp',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/root/node-sodium/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dmodule_root_dir=/root/node-sodium',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok

root@7el8ql:~/node-sodium# node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.10.10
gyp info using node@0.10.25 | linux | arm
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/root/node-sodium/build'
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/cr.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hmauth_hmacsha256_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hmref/hmac_hmacsha256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hmref/verify_hmacsha256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hm56/auth_hmacsha512256_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hm56/ref/hmac_hmacsha512256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_auth/hm56/ref/verify_hmacsha512256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/cry
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/curalsa20poly1305/box_curve25519xsalsa20poly1305_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/curalsa20poly1305/ref/after_curve25519xsalsa20poly1305.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/curalsa20poly1305/ref/before_curve25519xsalsa20poly1305.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/curalsa20poly1305/ref/box_curve25519xsalsa20poly1305.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_box/curalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/hsf2/core_hsalsa20.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/hsre_hsalsa20_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/sa/core_salsa20.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/sae_salsa20_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/saef/core_salsa2012.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/saore_salsa2012_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/saf/core_salsa208.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_core/sare_salsa208_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_genericto_generichash.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_generice2/generichash_blake2_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_generice2/ref/blake2b-ref.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_generice2/ref/generichash_blake2b.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hash/cr.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hash/sh_sha256_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hash/shhash_sha256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hash/sh_sha512_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hash/shhash_sha512.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hashblo6/ref/blocks_sha256.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hashblo6/hashblocks_sha256_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hashblo2/ref/blocks_sha512.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_hashblo2/hashblocks_sha512_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetimeto_onetimeauth.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/onetimeauth_poly1305.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/onetimeauth_poly1305_api.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/onetimeauth_poly1305_try.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/53/auth_poly1305_53.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/53/verify_poly1305_53.o
  CC(target) Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetime1305/donna/auth_poly1305_donna.o
In file included from ../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donoly1305_donna.c:6:0:
../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h:674: unable to emulate 'TI'
../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h: In 'shr128_pair':
../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h:747ng: left shift count >= width of type [enabled by default]
../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h: In 'hi128':
../deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h:767ng: right shift count >= width of type [enabled by default]
make: *** [Release/obj.target/libsodium/deps/libsodium-0.4.5/src/libsodium/crypto_onetimeau05/donna/auth_poly1305_donna.o] Error 1
make: Leaving directory `/root/node-sodium/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.8.13-bone50
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "build"
gyp ERR! cwd /root/node-sodium
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok    
@madenmud
Copy link

build at node_modules manually.

mkdir sodium
cd sodium
git clone https://github.com/paixaop/node-sodium.git
mv node-sodium/* ./
vi deps/libsodium-0.4.5/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h

-change deps/libsodium.gyp as below diff.

6c6,7
<                 'target_arch%': 'ia32'
---
>                 #'target_arch%': 'ia32'
>                 'target_arch%': 'arm'
15,16c16,17
<                     'HAVE_AMD64_ASM=1',
<                     'SODIUM_HAVE_AMD64_ASM',
---
>                     #'HAVE_AMD64_ASM=1',
>                     #'SODIUM_HAVE_AMD64_ASM',
38c39
<                     'HAVE_X86INTRIN_H=1',
---
>                     #'HAVE_X86INTRIN_H=1',
42,43c43,44
<                     'HAVE_AMD64_ASM=1',
<                     'HAVE_TI_MODE=1',
---
>                     #'HAVE_AMD64_ASM=1',
>                     #'HAVE_TI_MODE=1',
212c213
<                     'libsodium-<(naclversion)/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S',
---
>                     #'libsodium-<(naclversion)/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S',
238c239
< }
\ No newline at end of file
---
> }
  • then

node-gyp rebuild

@paixaop
Copy link
Owner

paixaop commented Oct 31, 2014

just updated lib sodium to 1.0.0 and removed the ASM code. so if you update the arch in the lib sodium.gyp it should work now.
Please let me know.

@madenmud
Copy link

madenmud commented Nov 3, 2014

It is working.

@paixaop paixaop closed this as completed Nov 15, 2014
@paixaop
Copy link
Owner

paixaop commented Nov 15, 2014

can you send me your gyp file so I can merge it?

@paixaop paixaop reopened this Nov 15, 2014
@Natim
Copy link

Natim commented Nov 25, 2014

FWIW I also reproduce this matter with i686 this means it works only on x86_64 apparently

@Natim
Copy link

Natim commented Nov 25, 2014

Here is what I had to change to compile it:

diff --git a/deps/libsodium.gyp b/deps/libsodium.gyp
index f05456f..9ded9aa 100755
--- a/deps/libsodium.gyp
+++ b/deps/libsodium.gyp
@@ -53,7 +53,7 @@
                     'HAVE_FENV_H=1',
                     'NATIVE_LITTLE_ENDIAN=1',
                     #'HAVE_AMD64_ASM=1',
-                    'HAVE_TI_MODE=1',
+                    #'HAVE_TI_MODE=1',
                     'HAVE_CPUID=1',
                     'HAVE_LIBM=1'
             ],

Then node-gyp rebuild

@Natim
Copy link

Natim commented Nov 25, 2014

I can confirm that this patch also works both on x86_64 and i686

@Natim
Copy link

Natim commented Nov 25, 2014

See #30

@r-arias
Copy link

r-arias commented Dec 18, 2014

@Natim Thanks, that fix enables me to compile master on 32bit. However, I get errors during make test:

Error: /home/emotest/node-sodium/build/Release/sodium.node: undefined symbol: crypto_scalarmult_curve25519
    at Error (native)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at Object.<anonymous> (/home/emotest/node-sodium/test/test_auth.js:5:14)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Module.require (module.js:357:17)
    at require (module.js:373:17)
    at /home/emotest/node-sodium/node_modules/mocha/lib/mocha.js:184:27
    at Array.forEach (native)
    at Mocha.loadFiles (/home/emotest/node-sodium/node_modules/mocha/lib/mocha.js:181:14)
    at Mocha.run (/home/emotest/node-sodium/node_modules/mocha/lib/mocha.js:393:31)
    at Object.<anonymous> (/home/emotest/node-sodium/node_modules/mocha/bin/_mocha:380:16)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Function.Module.runMain (module.js:490:10)
    at startup (node.js:124:16)
    at node.js:807:3
make: *** [test-unit] Error 1

It might be important to note that I am also using @jonasfj's patches in order to compile vs. node 0.11.13. If I pull his fork directly and try to compile that on 32 bit, setting #'HAVE_TI_MODE=1',, I get the same error.
I discovered the following:

node-sodium$ nm build/Release/sodium.node | grep scalarmult
0002dc80 T crypto_scalarmult
0002dc70 T crypto_scalarmult_base
0002dc40 T crypto_scalarmult_bytes
         U crypto_scalarmult_curve25519
         U crypto_scalarmult_curve25519_base
0002dc60 T crypto_scalarmult_primitive
0002dc50 T crypto_scalarmult_scalarbytes
000340a0 T crypto_sign_ed25519_ref10_ge_double_scalarmult_vartime
00035050 T crypto_sign_ed25519_ref10_ge_scalarmult_base
0001cdf0 T _Z22bind_crypto_scalarmultRKN2v820FunctionCallbackInfoINS_5ValueEEE
00017320 T _Z27bind_crypto_scalarmult_baseRKN2v820FunctionCallbackInfoINS_5ValueEEE

@r-arias
Copy link

r-arias commented Jan 14, 2015

Does anyone have a hint for me how to fix this?

@jonasfj
Copy link
Contributor

jonasfj commented Jan 14, 2015

this sounds like a libsodium issue, not a node-sodium issue... Or maybe it part of how libsodium gets build...
Either way, I don't really have any good ideas. Perhaps start with getting libsodium to build...

Is this arm or i686 too? And any suggestions for how to reproduce, maybe supply a vagrant box...

@paixaop
Copy link
Owner

paixaop commented Feb 19, 2015

can you try the develop branch?

@paixaop paixaop closed this as completed Feb 19, 2015
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

5 participants