一開始先試最新版的(v0.10.33) node.js, 結果最终 linking 階段,

爆出了大量 undefined reference to `v8::xxxxxxxx,

找同事幫忙, 最終決定照網路上某前輩的編譯流程, 再加以修改.

 

主要還是照這篇的做法,

http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html

加以整理修改如下: 

1. build V8:

(1) git clone https://github.com/paul99/v8m-rb.git -b dm-dev-mipsbe

(2) cd v8m-rb; make dependencies

(3) vim build.sh; chmod +x build.sh; ./build.sh

STAGING_DIR=/usr/local/CodeSourcery/Sourcery_G++_Lite/

PREFIX=$STAGING_DIR/bin/mips-linux-gnu-

export CC="${PREFIX}gcc -EL"

export CXX"=${PREFIX}g++ -EL"

export AR=${PREFIX}ar

export RANLIB=${PREFIX}ranlib

export LINK=$CXX

LIBPATH=$STAGING_DIR/lib/

export LDFLAGS='-Wl,-rpath-link '${LIBPATH}

export GYPFLAGS="-Dv8_use_mips_abi_hardfloat=false -Dv8_can_use_fpu_instructions=false"

make mipsel.release library=shared snapshot=off

 

有兩個主要的修改, 

(3)-1, "-EL" 是要它編成 little-endian

(3)-2, 原本的 make mips.release library=shared snapshot=off -j4 被改成 make mipsel.release library=shared snapshot=off

因為 make mips.release 預設編出 big-endian, 這會和 (3)-1 的修改衝突,

改成 make mipsel.release 就沒問題了. [2]

 

編出來的 libv8.so 會在 ./out/mipsel.release/lib.target/

 

 

2. build node.js:

(1) download node.js (v0.10.20)

(2) mkdir make-release

新增一資料夾存放 make install 結果

(3) vim build.sh; chmod +x build.sh; ./build.sh

V8SOURCE=/home/mingchengchang/v8m-rb

PREFIX=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/mips-linux-gnu-

LIBPATH=/usr/local/CodeSourcery/Sourcery_G++_Lite/lib/

export AR=${PREFIX}ar

export CC="${PREFIX}gcc -EL"

export CXX="${PREFIX}g++ -EL"

export RANLIB=${PREFIX}ranlib

export LINK=$CXX

export LDFLAGS='-Wl,-rpath-link '${LIBPATH}

export GYPFLAGS="-Dv8_use_mips_abi_hardfloat=false -Dv8_can_use_fpu_instructions=false"

make clean

make distclean

 ./configure --prefix=make-release --without-snapshot --shared-v8 --shared-v8-includes=${V8SOURCE}/include/ --shared-v8-libpath=${V8SOURCE}/out/mipsel.release/lib.target/

make snapshot=off -j4

make install

 

有兩個主要的修改, 

(3)-1, "-EL" 編成 little-endian

(3)-2, --prefix 指定 make install 的目標路徑

 

編出來的 node 會在 ./make-release/bin

 

 

3. 運行結果

node -v 成功

但隨便執行一個 js, 則爆出 segmentation fault

 

... 先卡在這裡吧 ...

 

 

Reference:

1. compile v8 & node.js

http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html

2. build v8 for mips

https://github.com/paul99/v8m-rb/wiki/Building-v8-for-MIPS-with-GYP

 

 

 

arrow
arrow
    全站熱搜

    kk 發表在 痞客邦 留言(0) 人氣()