Nodejs can not be built for a G4 processor (PowerPC 7455, as found in pre-Intel Apple hardware) because of a few missing CPU instructions. IBM has made a Power/PowerPC-port of V8 (the JavaScript engine of Nodejs), but it does not work with the G4.
However, there is a quite simple workaround that can probably work for other unsupported platforms (PowerPC G3) as well, but ARMv5 failed.
This solution is to emulate a supported (i386) CPU using Qemu. Qemu is capable of emulating an entire computer (qemu-system-i386) or just emulate for a single program/process (qemu-i386). That is what I do.
I am running Debian 7 on my G4 computer, which comes with an old version of Qemu. It is old enough to not support the system call ‘futex’ (system call 240). My suggestion is to simply use debian backports to install a much more recent version of qemu.
# Add to /etc/apt/sources.list deb http://http.debian.net/debian wheezy-backports main # Then run $ sudo apt-get update $ sudo apt-get -t wheezy-backports install qemu-user
Now you can use the command qemu-i386 to run i386 binaries. Download the i386 binary linux version of nodejs and extract it somewhere. I extracted mine in /opt and made a symlink to /opt/node for convenience. Now:
zo0ok@sleipnir:~$ qemu-i386 /opt/node/bin/node /lib/ld-linux.so.2: No such file or directory
Unless you want to build your own statically linked nodejs binary, you need to get a few libraries from an i386 linux machine. I put these in /opt/node/bin/lib:
zo0ok@sleipnir:/opt/node/bin/lib$ ls -l total 3320 -rw-r--r-- 1 zo0ok zo0ok 134380 mar 3 21:02 ld-linux.so.2 -rw-r--r-- 1 zo0ok zo0ok 1754876 mar 3 21:13 libc.so.6 -rw-r--r-- 1 zo0ok zo0ok 13856 mar 3 21:06 libdl.so.2 -rw-r--r-- 1 zo0ok zo0ok 113588 mar 3 21:12 libgcc_s.so.1 -rw-r--r-- 1 zo0ok zo0ok 280108 mar 3 21:11 libm.so.6 -rw-r--r-- 1 zo0ok zo0ok 134614 mar 3 21:12 libpthread.so.0 -rw-r--r-- 1 zo0ok zo0ok 30696 mar 3 21:05 librt.so.1 -rw-r--r-- 1 zo0ok zo0ok 922096 mar 3 21:08 libstdc++.so.6
For your convenience, I packed them for you:
https://dl.dropboxusercontent.com/u/9061436/code/linux-i386-lib.tgz
These are from Xubuntu 14.04.1 i386. The original symlinks are eliminated and the files come from different lib-folders. I packed exactly what you need to run the precompiled node-v0.12.0 binary.
Now you should be able to actually run nodejs:
$ zo0ok@sleipnir:~$ qemu-i386 -L /opt/node/bin/ /opt/node/bin/node --version v0.12.0
To make it 100% convenient I created /usr/local/bin/nodejs:
zo0ok@sleipnir:~$ cat /usr/local/bin/nodejs #!/bin/sh qemu-i386 -L /opt/node/bin /opt/node/bin/node "$@"
Dont forget to make it executable (chmod +x).
Performance is not amazing, but good enough for my purposes. It takes a few seconds to start nodejs, but when running it seems quite fast. I may post benchmarks in the future.