Re: [nodejs] Cross Compile nodejs for arm

2,584 views
Skip to first unread message

Ben Noordhuis

unread,
Sep 18, 2012, 7:33:13 AM9/18/12
to nod...@googlegroups.com
On Tue, Sep 18, 2012 at 1:22 PM, Sumit Aggarwal <getsu...@gmail.com> wrote:
> i want to cross compile nodejs for my Arm based board. After enough
> googling i am still not able to get it right.
> Can some one please refer some good document or summarize build procedure of
> nodejs for arm

It's pretty straightforward with v0.8:

$ CC=arm-linux-gcc ./configure --dest-cpu=arm

You can optionally specify the floating point ABI with
--with-arm-float-abi=soft|softfp|hard

Nathan Rajlich

unread,
Sep 18, 2012, 11:51:45 AM9/18/12
to nod...@googlegroups.com
I wrote a blog article about this very thing a couple weeks ago:
http://n8.io/cross-compiling-nodejs-v0.8

Cheers!
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
Message has been deleted

Sumit Aggarwal

unread,
Sep 19, 2012, 2:54:21 AM9/19/12
to nod...@googlegroups.com

Thanks Ban and Nathan
Actually i tried both the methods and get the error

NameError: name 'arm_neon' is not defined while evaluating condition 'arm_neon!=1 and arm_fpu!="vfpv3" and arm_fpu!="vfpv3-d16"' in /home/nodejs/deps/v8/tools/gyp/v8.gyp while loading dependencies of /home/nodejs/node.gyp while trying to load /home/nodejs/node.gyp

Does it mean that i need to cross compile v8 separately and then try to compile nodejs ?? or some configuration change is required ?

Sumit Aggarwal

unread,
Sep 19, 2012, 4:41:07 AM9/19/12
to nod...@googlegroups.com
Commented following portion in deps/v8/tools/gyp/v8.gyp  and compilation was success with --without-snapshot option 
  149                   'conditions': [
    150                     ['armv7==1', {
    151                       # The ARM Architecture Manual mandates VFPv3 if NEON is
    152                       # available.
    153                       # The current V8 doesn't use d16-d31, so for vfpv3-d16, we can
    154                       # also enable vfp3 for the better performance.
    155                       'conditions': [
    156 #        ['arm_neon!=1 and arm_fpu!="vfpv3" and arm_fpu!="vfpv3-d16"', {
    157 #                        'variables': {
    158 #                          'mksnapshot_flags': [
    159 #                            '--noenable_vfp3',
    160 #                           ],
    161 #                         },
    162 # }],
    163                       ],

i do not understand what is --without-snapshot option option and what commented portion does. can someone please telll
I need to run executable on my board and check for error if any !! 

Sumit Aggarwal

unread,
Sep 19, 2012, 5:44:54 AM9/19/12
to nod...@googlegroups.com

Able to run Test program on my embedded board. still i am thinking about
1.  compiling with --without-snapshot option. and how does it will effect the performance.
2. and modfication did in  deps/v8/tools/gyp/v8.gyp

can someone please explain the impact of these on my system's performance.

Ben Noordhuis

unread,
Sep 19, 2012, 6:51:32 AM9/19/12
to nod...@googlegroups.com
On Wed, Sep 19, 2012 at 10:41 AM, Sumit Aggarwal <getsu...@gmail.com> wrote:
> Commented following portion in deps/v8/tools/gyp/v8.gyp and compilation was
> success with --without-snapshot option
> 149 'conditions': [
> 150 ['armv7==1', {
> 151 # The ARM Architecture Manual mandates VFPv3
> if NEON is
> 152 # available.
> 153 # The current V8 doesn't use d16-d31, so for
> vfpv3-d16, we can
> 154 # also enable vfp3 for the better performance.
> 155 'conditions': [
> 156 # ['arm_neon!=1 and arm_fpu!="vfpv3" and
> arm_fpu!="vfpv3-d16"', {
> 157 # 'variables': {
> 158 # 'mksnapshot_flags': [
> 159 # '--noenable_vfp3',
> 160 # ],
> 161 # },
> 162 # }],
> 163 ],

Sumit, can you try this patch?

https://gist.github.com/9c4d01a7d3091398a1be

> i do not understand what is --without-snapshot option option and what
> commented portion does. can someone please telll
> I need to run executable on my board and check for error if any !!

--without-snapshot disables precompiling the built-in objects (Array,
String, etc.). There is a performance penalty but it's minor, it only
affects startup times.

Sumit Aggarwal

unread,
Sep 19, 2012, 8:27:38 AM9/19/12
to nod...@googlegroups.com

Hi Ben,
Patch did work for me. Thanks for the help

Ben Noordhuis

unread,
Sep 19, 2012, 8:59:31 AM9/19/12
to nod...@googlegroups.com
On Wed, Sep 19, 2012 at 2:27 PM, Sumit Aggarwal <getsu...@gmail.com> wrote:
> Hi Ben,
> Patch did work for me. Thanks for the help

Thanks for testing. Landed in master.

Sumit Aggarwal

unread,
Sep 20, 2012, 1:49:07 AM9/20/12
to nod...@googlegroups.com
Hello Ben and Moreira 
i want to use nodejs for enhancement of device capabilities and want to do something like this
1. Make device as http web server. something like done by nokia "http://research.nokia.com/page/231".
So that i can expose device capabilities to a web application and making device controllable by web like playing music, sharing data and may more.

2. Next step i have not decided yet but it should be something like supporting cross device web apps. 

But fist step is very important to understand if i can achieve what i want and i am into right direction. Step Zero (Porting nodejs is already complete with Ben's help )
Can you suggest some good reference for making device as REST web server. and easily map c++ APIs.


i am a C++ developer and new to js. so making me slower in develop something in JS.

P. Douglas Reeder

unread,
Sep 20, 2012, 2:19:08 PM9/20/12
to nod...@googlegroups.com
If you're not set on a particular device yet, you might pick up a used webOS device cheaply.  You're restricted to Node v0.2.3 on phones (Palm Pre 2 or HP Veer) and v0.4.12 on the HP TouchPad, but Node is already tested and optimized. Plus, you can easily write a front end to configure your website in JavaScript as well.

You can even distribute through the App Catalog: http://developer.palm.com/appredirect/?packageid=com.hominidsoftware.zapphotoshare

Ben Noordhuis

unread,
Oct 4, 2012, 10:45:29 PM10/4/12
to nod...@googlegroups.com
On Thu, Oct 4, 2012 at 10:22 PM, Jonathan Kunkee
<jonatha...@gmail.com> wrote:
> Ben,
>
> This patch fixes this for me. I have been fighting this since v0.6.19. Thank
> you!
>
> VFPv3 is the default for ARMv7, but not required:
> http://www.arm.com/products/processors/technologies/vector-floating-point.php
>
> These flags could be more reliably set from /proc/cpuinfo or the command
> line,
> but grokking compiler flags is more portable...
>
> Cheers,
> Jon Kunkee

Thanks Jon, good to know. Do you know if there are actual ARMv7 units
out there that don't support VFPv3? All the ARMv7 gear I have or know
of supports it. So far I haven't received bug reports either.

Jonathan Kunkee

unread,
Oct 5, 2012, 1:26:28 PM10/5/12
to nod...@googlegroups.com

> Thanks Jon, good to know. Do you know if there are actual ARMv7 units
> out there that don't support VFPv3? All the ARMv7 gear I have or know
> of supports it. So far I haven't received bug reports either.

I honestly don't know. There's a chance ARM would actually answer that
question, but that's asking about their customer base...

The two systems I have access to here at school are both armv7l and
support vfpv3.

I was thinking intelligently enabling NEON might be a performance boost,
but I have no idea how to benchmark that.

Cheers,
Jon

Ben Noordhuis

unread,
Oct 5, 2012, 4:17:46 PM10/5/12
to nod...@googlegroups.com
On Fri, Oct 5, 2012 at 7:26 PM, Jonathan Kunkee
<jonatha...@gmail.com> wrote:
> I was thinking intelligently enabling NEON might be a performance boost,
> but I have no idea how to benchmark that.

You mean adding NEON support to V8? Because it doesn't support it now,
only VFPv3.

Jonathan Kunkee

unread,
Oct 6, 2012, 4:38:34 PM10/6/12
to nod...@googlegroups.com
> You mean adding NEON support to V8? Because it doesn't support it now, 
> only VFPv3.

Point. I had assumed that the compiler could produce effective NEON
code, but using SIMD effectively often does require explicit use in code.
Adding it to the code would probably not be worth the cost for now.

Tom

unread,
Oct 28, 2013, 5:18:58 PM10/28/13
to nod...@googlegroups.com
Hello,

I also tried to cross compile Node.js v0.10.21 for an arm platform called armadeus, following instructions given by Nathan here : http://n8.io/cross-compiling-nodejs-v0.8/ but it fails with the following error messages :

/home/thomas/Armadeus/
armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-gcc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_GNU_SOURCE' '-DHAVE_CONFIG_H' -I../deps/uv/include -I../deps/uv/include/uv-private -I../deps/uv/src  -pthread -Wall -Wextra -Wno-unused-parameter -pthread -g --std=gnu89 -pedantic -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-tree-sink  -MMD -MF /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/.deps//home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/udp.o.d.raw  -c -o /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/udp.o ../deps/uv/src/unix/udp.c
  /home/thomas/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-gcc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_GNU_SOURCE' '-DHAVE_CONFIG_H' -I../deps/uv/include -I../deps/uv/include/uv-private -I../deps/uv/src  -pthread -Wall -Wextra -Wno-unused-parameter -pthread -g --std=gnu89 -pedantic -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-tree-sink  -MMD -MF /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/.deps//home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/proctitle.o.d.raw  -c -o /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/proctitle.o ../deps/uv/src/unix/proctitle.c
  /home/thomas/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-gcc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_GNU_SOURCE' '-DHAVE_CONFIG_H' -I../deps/uv/include -I../deps/uv/include/uv-private -I../deps/uv/src  -pthread -Wall -Wextra -Wno-unused-parameter -pthread -g --std=gnu89 -pedantic -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-tree-sink  -MMD -MF /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/.deps//home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o.d.raw  -c -o /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o ../deps/uv/src/unix/linux-core.c
../deps/uv/src/unix/linux-core.c:46:22: attention : ifaddrs.h : No such file or directory
../deps/uv/src/unix/linux-core.c: In function ‘uv_interface_addresses’:
../deps/uv/src/unix/linux-core.c:626: attention : implicit declaration of function ‘getifaddrs’
../deps/uv/src/unix/linux-core.c:633: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:634: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:634: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:635: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:636: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:651: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:653: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:653: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:657: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:665: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:669: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:671: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:672: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:674: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:677: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:682: attention : implicit declaration of function ‘freeifaddrs’
make[1]: *** [/home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o] Error 1
make[1]: Leaving directory `/home/thomas/Bureau/serveurWeb/node-v0.10.21/out'
make: *** [node] Error 2
thomas@thomas-laptop:~/Bureau/serveurWeb/node-v0.10.21$ make
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/thomas/Bureau/serveurWeb/node-v0.10.21/out'
  /home/thomas/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-gcc '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_GNU_SOURCE' '-DHAVE_CONFIG_H' -I../deps/uv/include -I../deps/uv/include/uv-private -I../deps/uv/src  -pthread -Wall -Wextra -Wno-unused-parameter -pthread -g --std=gnu89 -pedantic -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-tree-sink  -MMD -MF /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/.deps//home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o.d.raw  -c -o /home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o ../deps/uv/src/unix/linux-core.c
../deps/uv/src/unix/linux-core.c:46:22: attention : ifaddrs.h : No such file or directory
../deps/uv/src/unix/linux-core.c: In function ‘uv_interface_addresses’:
../deps/uv/src/unix/linux-core.c:626: attention : implicit declaration of function ‘getifaddrs’
../deps/uv/src/unix/linux-core.c:633: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:634: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:634: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:635: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:636: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:651: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:653: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:653: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:657: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:665: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:669: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:671: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:672: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:674: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:677: erreur: déréférencement d'un pointeur de type incomplet
../deps/uv/src/unix/linux-core.c:682: attention : implicit declaration of function ‘freeifaddrs’
make[1]: *** [/home/thomas/Bureau/serveurWeb/node-v0.10.21/out/Release/obj.target/libuv/deps/uv/src/unix/linux-core.o] Error 1
make[1]: Leaving directory `/home/thomas/Bureau/serveurWeb/node-v0.10.21/out'
make: *** [node] Error 2

As it says that ifaddrs.h is missing I tried to use the following configuration :
./configure --without-snapshot  --dest-cpu=arm --dest-os=linux ‐‐no‐ifaddrs

But it doesn't change anything.

Here after my exports:

export CC=~/Armadeus/armadeus-5.2/
buildroot/output/host/usr/bin/arm-linux-gcc
export AR=~/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-ar
export CXX=~/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-g++
export LINK=~/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-g++

Thanks in advance for your advices


Ben Noordhuis

unread,
Oct 28, 2013, 5:31:44 PM10/28/13
to nod...@googlegroups.com
--no-ifaddrs only does something on Solaris. The error message
suggests that either you don't have development headers installed or
that your system is seriously ancient. What do `uname -a`, `gcc -v`
and `cat /etc/issue` print?

Tom

unread,
Nov 13, 2013, 4:47:36 AM11/13/13
to nod...@googlegroups.com
Dear Ben,

Thanks for your quick reply and sorry for my very late one.

I tried the following script in the meanwhile but I still have the same error:
#! /bin/sh

export CROSS_COMPILE="/home/thomas/Armadeus/armadeus-5.2/buildroot/output/host/usr/bin/arm-linux-"
make clean
export AR="${CROSS_COMPILE}ar"
export AS="${CROSS_COMPILE}as"
export CC="${CROSS_COMPILE}gcc"
export CPP="${CROSS_COMPILE}gcc -E"
export CXX="${CROSS_COMPILE}g++"
export LD="${CROSS_COMPILE}g++"
export NM="${CROSS_COMPILE}nm"
export OBJDUMP="${CROSS_COMPILE}objdump"
export RANLIB="${CROSS_COMPILE}ranlib"
export STRIP="${CROSS_COMPILE}strip"

export CFLAGS="-march=armv5"
export CCFLAGS="-march=armv5"
export CXXFLAGS="-march=armv5"

./configure --without-snapshot
make


My system (on the PC) is the following:
thomas@thomas-laptop:~/Bureau/serveurWeb/node-v0.10.21$ cat /etc/issue
Ubuntu 12.04.3 LTS \n \l

thomas@thomas-laptop:~/Bureau/serveurWeb/node-v0.10.21$ uname -a
Linux thomas-laptop 3.2.0-56-generic #86-Ubuntu SMP Wed Oct 23 09:20:45 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
thomas@thomas-laptop:~/Bureau/serveurWeb/node-v0.10.21$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

the target is the following :
Linux armadeus 2.6.35.3 #22 PREEMPT Mon Jun 3 08:45:04 CEST 2013 armv5tejl GNU/Linux

What do you mean by
you don't have development headers installed
?

Thanks in advance

Best regards,
Thomas
Reply all
Reply to author
Forward
0 new messages