5

I cross compiled nodejs 0.12.2 for Atmel SAMA5D36 using following tool chain

export AR=arm-linux-gnueabihf-ar
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export LINK=arm-linux-gnueabihf-g++

and configured and build as follows

./configure --without-snapshot --dest-cpu=arm --dest-os=linux --prefix=/home/root/nodejs-v0.12.2

make make install DESTDIR=/home/user/Desktop/nodejs_arm/nodebins

The compiled folder is generated inside /home/user/Desktop/nodejs_arm/nodebins/home/root

I compressed that folder into a tar file and transferred to AtmelSAMA5D36 arm board.I uncompressed it on the board in /home/root directory and created following symbolic link

ln -s /home/root/nodejs-v0.12.2/bin/npm /bin/npm
ln -s /home/root/nodejs-v0.12.2/bin/node /bin/node

when I test it using "node -v" and "npm -v" ,

"node -v" gives correct output but

"npm -v" throwing "illegal instruction" error
same with "node".

However cross compiled nodejs 0.10.40 is working totally fine.

Any help is highly appreciated.

Update:

(gdb) run
Starting program: /usr/bin/node
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0xb6edfec0 in _armv7_neon_probe () from /usr/lib/libcrypto.so.1.0.0
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
0xb6edfec8 in _armv7_tick () from /usr/lib/libcrypto.so.1.0.0
(gdb) c
Continuing.
[New Thread 0xb65ca4c0 (LWP 3774)]
[New Thread 0xb67ca4c0 (LWP 3773)]
[New Thread 0xb69ca4c0 (LWP 3772)]
[New Thread 0xb6bca4c0 (LWP 3771)]

Program received signal SIGILL, Illegal instruction.
0x0054b504 in v8::internal::ComputeFlagListHash() ()
(gdb) c
Continuing.
[Thread 0xb65ca4c0 (LWP 3774) exited]
[Thread 0xb67ca4c0 (LWP 3773) exited]
[Thread 0xb69ca4c0 (LWP 3772) exited]
[Thread 0xb6bca4c0 (LWP 3771) exited]

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb) q
# gdb node -e 0
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-buildroot-linux-uclibcgnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...
(gdb)
(gdb) run
Starting program: /usr/bin/node
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0xb64f84c0 (LWP 14382)]
[New Thread 0xb66f84c0 (LWP 14381)]
[New Thread 0xb68f84c0 (LWP 14380)]
[New Thread 0xb6af84c0 (LWP 14379)]

Program received signal SIGILL, Illegal instruction.
0x0054b504 in v8::internal::ComputeFlagListHash() ()
(gdb)
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/bin/node
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0xb653d4c0 (LWP 14531)]
[New Thread 0xb673d4c0 (LWP 14530)]
[New Thread 0xb693d4c0 (LWP 14529)]
[New Thread 0xb6b3d4c0 (LWP 14528)]

Program received signal SIGILL, Illegal instruction.
0x0054b504 in v8::internal::ComputeFlagListHash() ()
(gdb) Program received signal SIGILL, Illegal instruction.
Undefined command: "Program".  Try "help".
(gdb) 0x0054b504 in v8::internal::ComputeFlagListHash() ()bt
Undefined command: "0x0054b504".  Try "help".
(gdb) bt
#0  0x0054b504 in v8::internal::ComputeFlagListHash() ()
#1  0x007b8a54 in v8::internal::V8::InitializeOncePerProcessImpl() ()
#2  0x009281b0 in v8::base::CallOnceImpl(int*, void (*)(void*), void*) ()
#3  0x007b8ba8 in v8::internal::V8::Initialize() ()
#4  0x0028fc74 in v8::V8::Initialize() ()
#5  0x00897a34 in node::Start(int, char**) ()
#6  0xb6b95634 in __uClibc_main () from /lib/libc.so.1
#7  0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) q
CaptainBli
  • 4,121
  • 4
  • 39
  • 58
  • Can you output the result of `node --v8-options` – Corbin Sep 17 '15 at 11:28
  • First few lines of output of node --v8-options are as follows – Mohammed Arif Sep 17 '15 at 12:35
  • 1
    target arm v7 vfp3 hard ARMv7=1 VFP3=1 VFP32DREGS=1 NEON=0 SUDIV=0 UNALIGNED_ACCESSES=1 MOVW_MOVT_IMMEDIATE_LOADS=0 USE_EABI_HARDFLOAT=1 – Mohammed Arif Sep 17 '15 at 12:35
  • Did you ever figure out how to solve this? – CaptainBli May 16 '17 at 21:42
  • @MohammedArif sometimes the issue is that the `npm` isn't the correct version when installing `node` if that gives any tips, else you could also try cleaning cache of `npm` http://stackoverflow.com/a/43763627/7707749 – King Reload May 22 '17 at 07:22
  • @KingReload so what you are saying is that maybe because buildroot doesn't have the right version of `npm` that it is throwing the "Illegal Instruction"? – CaptainBli May 22 '17 at 14:34
  • @CaptainBli `npm` might install with the wrong version that is provided with the `node` install. However he could also try to start a new session or use the `bash` command to use the new `node` and `npm` path variables. As well in his last comment he said using `ARMv7=1` which hints that V8 is compiled for ARMv7. – King Reload May 22 '17 at 14:46
  • I have tried building it with a whole bunch of different parameter changes. It does try to compile with ARMv7. Apparently the crypto lib isn't correctly compiled. So we rebuilt that. Now we get past that issue there is still another messed up lib or config that is not working. I guess I am hoping someone has compiled this for SAMA5. @KingReload I don't think Mohammed will read this. I put the bounty to try to get answers – CaptainBli May 23 '17 at 18:44
  • @CaptainBli could you explain what compile error you're getting right now? – King Reload May 24 '17 at 06:59
  • @KingReload I'm not getting compiler errors, just execution errors. lib crypto which came from buildroot gave us the wrong version, which is required by node, v8. Let me get some details and I will add it to the question. – CaptainBli May 24 '17 at 18:20

1 Answers1

2

We had a similar issue trying to use nodejs 6.1.0 via a buildroot toolchain on SAMA5D31, and ran into the same "Illegal instruction" issues. Finally we switched to using version 0.10.45 which is included in buildroot for older processors (armv5 and older).

In troubleshooting this, the problem appears to be in nodejs and OpenSSL libraries used by node where the compiled code is attempting to use Neon instructions for floating point operations. The SAMA5D3X processor reports as an armV7, but does not have a Neon FPU. However, nodejs (and openssl for us) are trying to use Neon instructions because it assumes as an armV7 it has them. Until nodejs can handle a non-Neon armV7, the best option is to use the 0.10.40 or 0.10.45 version of node until that can be resolved. Or modify the build configuration yourself for node to handle the non-Neon armV7.

A. Blodgett
  • 136
  • 7