OpenWrt Forum Archive

Topic: nodejs package

The content of this topic has been archived on 24 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Has anyone tried to make nodejs a package for openwrt ?

http://www.nodejs.org/

From what I've read here and there, it seems v8 doesn't fully support mips, or is buggy, so I guess at least in the case of mips SoCs that's going to take some effort to get going, if at all possible.

looks like there is attempt to run v8 on mips and arm architecture.

https://github.com/paul99/v8m-rb

but there compilation uses Scon, so it is a bit hard to convert into openwrt package system.

today, I was trying to build this myself. and it failed.
as it support makefile in gyp way, I setted cross compiler environment variable. and tried to compile.

https://github.com/paul99/v8m-rb/wiki/B … S-with-GYP

Environment Variable Setup

export CC=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-gcc
export CXX=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-g++
export AR=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ar
export LD=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ld
export RANLIB=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ranlib
export LDFLAGS="-static"
export CFLAGS="-Os -s -mips32r2 -mtune=mips32r2 -funit-at-a-time"
export GYP_DEFINES="-Dtarget_arch=mips"

Error Message

[nikescar@localhost v8m-rb]$ make mips.release V=99
make[1]: Entering directory `/home/nikescar/nodejssrc/v8m-rb/out'
  /home/nikescar/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-g++ '-DENABLE_DEBUGGER_SUPPORT' '-DV8_TARGET_ARCH_MIPS' '-DCAN_USE_FPU_INSTRUCTIONS' '-D__mips_hard_float=1' '-D_MIPS_ARCH_MIPS32R2' -I../src  -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pthread -fno-rtti -fno-exceptions -pedantic -ansi -fvisibility=hidden -m32 -fdata-sections -ffunction-sections -fomit-frame-pointer -O3  -MMD -MF /home/nikescar/nodejssrc/v8m-rb/out/mips.release/.deps//home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o.d.raw  -c -o /home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o ../src/allocation.cc
cc1plus: error: unrecognized command line option "-m32"
make[1]: *** [/home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o] Error 1
make[1]: Leaving directory `/home/nikescar/nodejssrc/v8m-rb/out'
make: *** [mips.release] Error 2

googling on error message came up with this link.

http://code.google.com/p/chromium/issue … l?id=31274

but I am not sure its related.


I tried to exterminate the code that generate -m32 option. which is exist in /build/common.gyp.

['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
         or OS=="netbsd"', {
        'conditions': [
          [ 'target_arch=="ia32"', {
            'cflags': [ '-m32' ],
            'ldflags': [ '-m32' ],
          }],
          [ 'v8_no_strict_aliasing==1', {
            'cflags': [ '-fno-strict-aliasing' ],
          }],
        ]

change it to

['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
         or OS=="netbsd"', {
        'conditions': [
          [ 'target_arch=="ia32"', {
            'cflags': [ '' ],
            'ldflags': [ '' ],
          }],
          [ 'v8_no_strict_aliasing==1', {
            'cflags': [ '-fno-strict-aliasing' ],
          }],
        ]

it became this error.

[nikescar@localhost v8m-rb]$ make mips.release V=99
build/gyp/gyp --generator-output="out" build/all.gyp \
                      -Ibuild/standalone.gypi --depth=. -Ibuild/mipsu.gypi \
                      -S-mips  -Dv8_can_use_vfp_instructions=true
make[1]: Entering directory `/home/nikescar/nodejssrc/v8m-rb/out'
  /home/nikescar/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-g++ '-DENABLE_DEBUGGER_SUPPORT' '-DV8_TARGET_ARCH_MIPS' '-DCAN_USE_FPU_INSTRUCTIONS' '-D__mips_hard_float=1' '-D_MIPS_ARCH_MIPS32R2' -I../src  -Wall -Werror -W -Wno-unused-parameter -Wnon-virtual-dtor -pthread -fno-rtti -fno-exceptions -pedantic -ansi -fvisibility=hidden -fdata-sections -ffunction-sections -fomit-frame-pointer -O3  -MMD -MF /home/nikescar/nodejssrc/v8m-rb/out/mips.release/.deps//home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o.d.raw  -c -o /home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o ../src/allocation.cc
In file included from ../src/allocation.h:31,
                 from ../src/allocation.cc:28:
../src/globals.h:90:2: error: #error Host architecture was not detected as supported by v8
../src/globals.h:124:2: error: #error Target architecture mips is only supported on mips and ia32 host
make[1]: *** [/home/nikescar/nodejssrc/v8m-rb/out/mips.release/obj.target/preparser_lib/src/allocation.o] Error 1
make[1]: Leaving directory `/home/nikescar/nodejssrc/v8m-rb/out'
make: *** [mips.release] Error 2

(Last edited by nikescar on 13 Mar 2012, 13:44)

Their makefile just hardcodes flags which are inappropriate for non-x86 arches. Simply patch out the -m32.

I was modified the contents above while you write reply.
in my linux,  'uname -m' reports x86_64.
does this mean I can't compile on this machine?
do I need ia32 machine to compile?

Maybe - so far it looks to me like yet another crappy broken build system.

thanks. I need to look for ia32 architecture.

I issued to github source. and they came back with solution but it made another problem.

https://github.com/paul99/v8m-rb/issues/3

I am looking for solution for finding execinfo.h


export CC=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-gcc
export CXX=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-g++
export AR=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ar
export LD=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ld
export RANLIB=~/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-ranlib

[nikescar@localhost v8m-rb]$ scons arch=mips mode=release sample=shell
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
/home/nikescar/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/mips-openwrt-linux-uclibc-g++ -o obj/release/platform-linux.o -c -fno-rtti -fno-exceptions -fvisibility=hidden -Wall -Werror -W -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -pedantic -EL -mhard-float -mips32r2 -Wa,-mips32r2 -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -D_MIPS_ARCH_MIPS32R2 -DV8_TARGET_ARCH_MIPS -DENABLE_DEBUGGER_SUPPORT -Isrc src/platform-linux.cc
src/platform-linux.cc:50:56: error: execinfo.h: No such file or directory
src/platform-linux.cc: In static member function 'static int v8::internal::OS::StackWalk(v8::internal::Vectorv8::internal::OS::StackFrame)':
src/platform-linux.cc:564: error: 'backtrace' was not declared in this scope
src/platform-linux.cc:566: error: 'backtrace_symbols' was not declared in this scope
scons: *** [obj/release/platform-linux.o] Error 1
scons: building terminated because of errors.

(Last edited by nikescar on 14 Mar 2012, 08:24)

So, the answer is that V8 doesn't support big endian. period.

mius period. smile
found nodejs on spidermonkey javascript engine(not v8 engine).

spidermonkey source(mozilla-central/js/src )
https://github.com/doublec/mozilla-central

v8monkey(v8-api interpreter for spidermonkey)
https://github.com/zpao/v8monkey

spidernode(node on spider using v8monkey)
https://github.com/zpao/spidernode

I will try and report.

it seems that it is bit hard to cross-compile.

https://developer.mozilla.org/en/Buildi … iderMonkey

http://old.nabble.com/about-SpiderMonke … 85220.html

could anyone give me a pointer to set compile environment?

(Last edited by nikescar on 14 Mar 2012, 22:05)

I saw that there is a port of Node.JS for Raspberry Pi now, does that make any difference for OpenWrt ?

No.

I don't see how a port of something to ARM would help for MIPS.

Hi guys,

can anyone please confirm if its possible to get Node.js running on OpenWrt, I've check the links but there are no proof/tutorials/blogs that I can find to confirm this.

I'm trying to port some webapps that I have already been running in some other linux embedded boards (Debian based - ARM), I'm currently evaluating the TP-Link WR703N for a possible device (currently running OpenWrt), It could help if someone could point me in the right direction. I'm currently installing the required tools to set the cross-environment building system in a VM Debian machine.

Regards,
Nelson Neves.

Hi guys,
Any updates on this?
The following openwrt wiki page kind of suggests that it works...
http://wiki.openwrt.org/nodejs

I wasn't able to build it yet, but that's partly because one of the svn sources are down (svn.nomi.cz)

The source and instructions on that wiki page work for me. NPM isn't part of that package, however. But, since NPM isn't compiled, it should be relatively straightforward to add the NPM subsystem. I haven't decided yet if I'm that ambitious ;-)

Edit: Building didn't work for me on a 64-bit compiler machine but it worked fine on a 32-bit.

(Last edited by brnt on 27 Jul 2014, 03:29)

Hi guys,

I got this working but with some really hard work, haven't got the opportunity to write down stuff ... I'll leave you with some links if you really want to CrossCompile it yourself, nevertheless I would suggest to use the above instructions http://wiki.openwrt.org/nodejs (much easier process)

Base discussion on gist:
https://github.com/paul99/v8m-rb/pull/1 … t-23875964

Arduino Yun (also uses AR9331)
http://fibasile.github.io/compiling-nod … o-yun.html

http://giorgiocefaro.com/blog/installin … rduino-yun

OpenWrt Node.js Package (source of the http://wiki.openwrt.org/nodejs solution)
https://github.com/brimstone/nodejs-openwrt

For the NPM packages that are pure Javascript code (will not compile stuff with node-gyp + gcc) you can install it on a standard X86 machine using linux, tar it and send it to the OpenWrt AR9331 based system such as the TP Link WR703N, untar it and you are ready to go, the other modules such as SerialPort it is required to cross compile it in the OpenWrt environment, the 1st link explains how to do this (prepare yourself for a long reading)

Hope this helps!

(Last edited by botdream on 27 Jul 2014, 13:25)

I am struggling with getting http://wiki.openwrt.org/nodejs installable. the instructions here show a menuconfig item that doesn't exist on my AttitudeAdjustment menuconfig...

I have tried to go the box.net folder to get the latest built ipkg however it says that the file is 404 forbidden.

I am not sure how I add the source to the openWRT build environement I have... My goal is to test node.js on a new router and gateway board we are developing any help with either sending a link to the ipkg for the latest build with the patch as mentioned or instructions to how to integrate the source into the package build system fro attitude adjustment would be really appreciated.

Thanks in advance

Hi,

I've made a script to cross-compile Node.js Binary for the AR9331 SoC based routers/boards, maybe this could help you to get the binary compiled:

https://github.com/nneves/openwrt_mips_ar9331_nodejs/

(you will need to run nodejs_v0.10.5_mips_ar9331.sh after cloning the repository)

I've tested this on a Linux Debian Image, it will download all the dependencies required, node.js/v8 source code, etc etc...

Please note that this was based on the solution presented in my previous links and so in order to work as expected it will link to specific OpenWrt, node.js and v8 versions (and not the most recent one).

Are there any NodeJS binary OpenWrt CC packages for ar71xx platform available  ?

The discussion might have continued from here.