Compiling node.js on a 32-bit system

I need to compile node.js on a 32-bit system for compatibility with existing code.

I started with the source code from nodejs.org and compiled it. Then I started by changing lines 164-166 in the common.gypi file. It was:

164 [ 'target_arch=="x64"', { 165 'cflags': [ '-m64' ], 166 'ldflags': [ '-m64' ], 167 }], 

and now this:

 164 [ 'target_arch=="x64"', { 165 'cflags': [ '-m32' ], 166 'ldflags': [ '-m32' ], 167 }], 

When I tried to do this again, I get the following errors:

../deps/v8/src/execution.h: 259: error: integer constant too large for long type .. / deps / v 8 / src / execution.h: 260: error: integer constant too large for long type .. / deps / v 8 / src / execution.h: 259: error: function call cannot appear in constant expression .. / deps / v 8 / src / execution.h: 260: error: function call cannot appear in constant expression

These errors relate to these lines:

 #ifdef V8_TARGET_ARCH_X64 static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe); static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8); 

I believe this code is from google v8 source code.

I would appreciate any suggestions on how to fix these specific compilation errors and / or how to compile 64-bit node.js on a 32-bit system. Most of the research I have done is how to compile something 32-bit for a 64-bit system.

+4
source share
1 answer

If you want to build the x86_32 node version, you are changing the settings for the wrong target architecture. Instead, specify the --dest-cpu parameter in the configure script, for example:

 git clone git://github.com/joyent/node.git cd node ./configure --prefix /usr/local --dest-cpu ia32 make 

If these commands completed successfully, ./out/Release/node should be a working x86_32 binary version in ./out/Release/node:

 ~/node$ file -b ./out/Release/node ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, (...), not stripped ~/node$ ./out/Release/node > 1 + 1 2 

You can install it on your operating system (in the prefix specified in the --prefix option above) using sudo make install .

Please note that this requires the creation of a working C and C ++ compiler. In Debian / Ubuntu, sudo apt-get install build-essential (or build-essential:i386 if you are cross-compiling), you should start. On rpm based distributions try sudo yum groupinstall "Development Tools" "Development Libraries" .

+5
source

All Articles