SynoCommunity / spksrc

Cross compilation framework to create native packages for the Synology's NAS
https://synocommunity.com
Other
3.02k stars 1.23k forks source link

Node.js #436

Closed guillaume86 closed 11 years ago

guillaume86 commented 11 years ago

Hi,

It would be nice to have a Node.js package, I've tried to cross compile it myself but I'm not experienced at all with makefiles and I got stuck pretty quickly:

....
/configure  --host=arm-none-linux-gnueabi --build=i686-pc-linux --prefix=/usr/local --dest-cpu=arm --dest-os=linux
Usage: configure [options]

configure: error: no such option: --host

I guess this flag is injected by a mk file but I haven't found it yet, It would probably take me ages to finish the compilation at the speed I figure things out so I'm better off just submitting a request :)

Thx for your work on the syno, your packages are must have...

guillaume86 commented 11 years ago

Ok I got a bit further (stuck at install step), here's my Makefile (the arch is harcoded in config args for the moment):

PKG_NAME = node
PKG_VERS = 0.8.22
PKG_EXT = tar.gz
PKG_DIST_NAME = node-v$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = http://nodejs.org/dist/v$(PKG_VERS)
PKG_DIR = node-v$(PKG_VERS)

HOMEPAGE = http://www.nodejs.org/
COMMENT  = Evented I/O for V8 javascript.
LICENSE  =

# Configure
CONFIGURE_ARGS = --without-snapshot --dest-cpu=arm --dest-os=linux

# Install
#INSTALL_TARGET = myInstall
#POST_INSTALL_TARGET = $(WORK_DIR)/node-cc.mk

include ../../mk/spksrc.cross-cc.mk

and the error:

===>  Building package for arch 88f6281
make[1]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node »
===>  Installing for node
find /home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/ \! -type d -printf '%P\n' | sort > /home/guillaume/spksrc/cross/node/work-88f6281/node.plist.tmp
cd /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 && env PKG_CONFIG_LIBDIR=/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib/pkgconfig WORK_DIR=/home/guillaume/spksrc/cross/node/work-88f6281 INSTALL_PREFIX=/usr/local TC=syno-88f6281  LD=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-g++ CPP=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-cpp NM=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-nm CC=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc AS=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-as RANLIB=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ranlib CXX=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-g++ AR=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ar STRIP=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-strip OBJDUMP=/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-objdump CFLAGS=" -I/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/include " CPPFLAGS=" -I/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/include " CXXFLAGS=" -I/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/include " LDFLAGS=" -L/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath-link,/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath,/usr/local/lib " make install prefix=/home/guillaume/spksrc/cross/node/work-88f6281/install/usr/local
make[2]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 »
make -C out BUILDTYPE=Release V=1
make[3]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out »
  /home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld -pthread -rdynamic -pthread  -L/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath-link,/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath,/usr/local/lib  -o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/node -Wl,--start-group /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/fs_event_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/cares_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/handle_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_buffer.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_constants.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_extensions.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_file.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_http_parser.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_javascript.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_main.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_os.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_script.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_stat_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_string.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_zlib.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/pipe_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/stream_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/slab_allocator.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/tcp_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/timer_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/tty_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/process_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/v8_typed_array.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/udp_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_crypto.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_signal_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_io_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/http_parser/libhttp_parser.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/uv/libuv.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/openssl/libopenssl.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/zlib/libchrome_zlib.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a -Wl,--end-group -lm -ldl -lrt
/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld: bad -rpath option
make[3]: *** [/home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/node] Erreur 1
make[3]: quittant le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out »
make[2]: *** [node] Erreur 2
make[2]: quittant le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 »
make[1]: *** [install_target] Erreur 2
make[1]: quittant le répertoire « /home/guillaume/spksrc/cross/node »
make: [arch-88f6281] Erreur 2 (ignorée)
guillaume86 commented 11 years ago

I guess the problem is related to:

http://n8.io/cross-compiling-nodejs-v0.8/

$ export LINK=arm-unknown-linux-gnueabi-g++

Note that the LINK variable points to your g++ program rather than your ld program, since the Makefile uses some flags that ld does not recognize.

but I can't find where to change this in spksrc

Diaoul commented 11 years ago

In your Makefile, try this:

ENV += LINK=$(TC_PREFIX)g++
guillaume86 commented 11 years ago

Hi,

It didn't work unfortunatly (the command still uses ld).

I found a patch to skip the bad --rpath option problem (http://patches.openembedded.org/patch/38821/), but there's another problem immediatly after that (same problem than before I think):

===>  Building package for arch 88f6281
make[1]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node »
===>  Compiling for node
make[2]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 »
python tools/gyp_node -f make
make -C out BUILDTYPE=Release V=1
make[3]: entrant dans le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out »
  /home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld -pthread -pthread  -L/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath-link,/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib -Wl,--rpath,/usr/local/lib  -o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/node -Wl,--start-group /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/fs_event_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/cares_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/handle_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_buffer.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_constants.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_extensions.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_file.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_http_parser.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_javascript.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_main.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_os.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_script.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_stat_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_string.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_zlib.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/pipe_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/stream_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/slab_allocator.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/tcp_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/timer_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/tty_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/process_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/v8_typed_array.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/udp_wrap.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_crypto.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_signal_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/node/src/node_io_watcher.o /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/http_parser/libhttp_parser.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/uv/libuv.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/openssl/libopenssl.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/zlib/libchrome_zlib.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a -Wl,--end-group -lm -ldl -lrt
/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld: unrecognized option '-Wl,--rpath-link,/home/guillaume/spksrc/cross/node/work-88f6281/install//usr/local/lib'
/home/guillaume/spksrc/toolchains/syno-88f6281/work/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-ld: use the --help option for usage information
make[3]: *** [/home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out/Release/node] Erreur 1
make[3]: quittant le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22/out »
make[2]: *** [node] Erreur 2
make[2]: quittant le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 »
make[1]: *** [compile_target] Erreur 2
make[1]: quittant le répertoire « /home/guillaume/spksrc/cross/node »
make: [arch-88f6281] Erreur 2 (ignorée)
guillaume86 commented 11 years ago

I'll take a look at http://www.nodejs-news.com/nodejs-tech/ruby-to-build-nodejs-raspberrypi/ if I've still got the courage this weekend

Diaoul commented 11 years ago

IMO you just need to redefine LD. Use a custom compile target which runs $(RUN) $(MAKE) LD=$(TC_PATH)$(TC_PREFIX)g++ so you override LD defined by the environment.

guillaume86 commented 11 years ago

Ok with your suggestion + the patch, I can get further, this time it looks easier: trying to install in a system path and have not the rights, I have to customize the install step to install locally I guess:

...
make install prefix=/home/guillaume/spksrc/cross/node/work-88f6281/install/usr/local
Traceback (most recent call last):
  File "tools/install.py", line 234, in <module>
    run(sys.argv[:])
  File "tools/install.py", line 229, in run
    if cmd == 'install': return files(install)
  File "tools/install.py", line 191, in files
    'include/node/')
  File "tools/install.py", line 79, in install
    def install(paths, dst): map(lambda path: try_copy(path, dst), paths)
  File "tools/install.py", line 79, in <lambda>
    def install(paths, dst): map(lambda path: try_copy(path, dst), paths)
  File "tools/install.py", line 69, in try_copy
    try_mkdir_r(os.path.dirname(target_path))
  File "tools/install.py", line 44, in try_mkdir_r
    os.makedirs(path)
  File "/usr/lib/python2.6/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/include/node'
make[2]: *** [install] Erreur 1
make[2]: quittant le répertoire « /home/guillaume/spksrc/cross/node/work-88f6281/node-v0.8.22 »
make[1]: *** [install_target] Erreur 2
make[1]: quittant le répertoire « /home/guillaume/spksrc/cross/node »
make: [arch-88f6281] Erreur 2 (ignorée)
Diaoul commented 11 years ago

Override the install target this time with $(RUN) $(MAKE) install DESTDIR=$(INSTALL_DIR). This is a common way to install in a destination directory so it might work.

guillaume86 commented 11 years ago

Thanks I almost found this one alone before you replied ^^

It works now, but it stops without errors after that step, perhaps I have to write the PLIST file now?

Diaoul commented 11 years ago

PLISTS are auto-generated in the work directory. Just pick nodejs.plist in there and copy it to PLIST. Remove the junk in it and give the correct prefixes.

guillaume86 commented 11 years ago

I finally got a package out and it's working! Thx a lot

The build process is not clean, if I apply the patch automatically I have the ld issue, I got to launch make a first time, waiting for the first ld error, applying the patch manually then relaunch make and the compile/install finishes.

Then I had to copy paste the PLIST and the work-ARCH folder to the /spk/node, set the arch in the makefile and make from there - no idea why it's not working automatically.

Diaoul commented 11 years ago

You don't need to set the ARCH in the Makefile, just run make ARCH=qoriq for example. Could you link me the patch? If it does patch a .in file make sure to run autoconf in the pre-configure target.

guillaume86 commented 11 years ago

Ok I'll try that, here's the patch:

*** common.gypi.orig    2013-03-08 20:58:10.000000000 +0100
--- common.gypi 2013-03-08 20:58:47.000000000 +0100
***************
*** 164,170 ****
        [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
          'cflags': [ '-Wall', '-pthread', ],
          'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
!         'ldflags': [ '-pthread', '-rdynamic' ],
          'conditions': [
            [ 'target_arch=="ia32"', {
              'cflags': [ '-m32' ],
--- 164,170 ----
        [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
          'cflags': [ '-Wall', '-pthread', ],
          'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
!         'ldflags': [ '-pthread' ],
          'conditions': [
            [ 'target_arch=="ia32"', {
              'cflags': [ '-m32' ],
guillaume86 commented 11 years ago

So the preConfigure don't work because it's not a .in file (my bad), I setup a fork if you want to take a look https://github.com/guillaume86/spksrc

guillaume86 commented 11 years ago

The solution is probably to patch a node makefile to switch ld to g++ at the right time

Rapiere commented 11 years ago

if it could help you, I issued a pull request with latest Node.js which compiled for arm architecture however I couldn't test it (only tested cedarview on my ds412+).

Diaoul commented 11 years ago

I'll merge this once tested

guillaume86 commented 11 years ago

Nice! I'll use that package if it's working :)

2013/4/23 Antoine Bertin notifications@github.com

I'll merge this once tested

— Reply to this email directly or view it on GitHubhttps://github.com/SynoCommunity/spksrc/issues/436#issuecomment-16851888 .