Peter's Solaris Zone

Building Node

I've been producing Node.JS packages for Solaris 10 for a long time. The following notes describe how those packages are built, and the changes that I needed to make.

First, you're going to need a reasonably up to date version of GCC. For the 0.x series, 4.6 should be sufficient; for v4 and later you need at least 4.8. In the following, I'm going to call the prefix for GCC $GROOT, so that the gcc binary should be located at $GROOT/bin/gcc.

There are a few places where the build (or npm at runtime) assumes GNU tools.

You need to decide where you want Node to be installed. I'm going to call that $NROOT, which for my builds was /opt/Node.

0.10

Unpack the source tarball and cd into the node-vXXX directory. Replace tools/gyp/pylib/gyp/input.py with this file. (If you're interested, look for FixupSolarisShell.)

gsed -i s:objdump:gobjdump: tools/genv8constants.py

env CC=gcc CXX=g++ LDFLAGS=-R$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH ./configure --no-ifaddrs --prefix=$NROOT

env LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake -j 3

env LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake install

0.12

Unpack the source tarball and cd into the node-vXXX directory. Replace tools/gyp/pylib/gyp/input.py with this file. (That's the same as 0.10.)

In the file deps/v8/src/allocation.cc, replace

if (posix_memalign(&ptr, alignment, size)) ptr = NULL;

with

ptr = memalign(alignment, size);

In the file deps/uv/src/unix/fs.c, add the following

char* mkdtemp( char * template )
{
if( !mktemp( template ) || mkdir( template, 0700 ) )
    return NULL;
return template;
}

just before where mkdtemp is called.

In the file src/node_os.cc add a missing return at about line 242,
where it says

  if (err == UV_ENOSYS) {
    args.GetReturnValue().Set(ret);

that should be

  if (err == UV_ENOSYS) {
    args.GetReturnValue().Set(ret);
    return;

Then:
  
gsed -i 's:-lnsl:-lsocket -lnsl -lrt:' deps/v8/tools/gyp/v8.gyp
gsed -i s:objdump:gobjdump: tools/genv8constants.py
gsed -i 's:node_use_mdb=="true":node_use_mdb=="false":' node.gyp

env CC=gcc CXX=g++ LDFLAGS=-R$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH ./configure --without-dtrace --no-ifaddrs --prefix=$NROOT

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake install

v4

Remember, from this point you definitely need gcc 4.8 or later.

Apply similar fixes to the files deps/v8/src/allocation.cc (posix_memalign) and deps/uv/src/unix/fs.c (mkdtemp) as were necessary in 0.12.

gsed -i 's:-lnsl:-lsocket -lnsl -lrt:' deps/v8/tools/gyp/v8.gyp
gsed -i s:objdump:gobjdump: tools/genv8constants.py

env CC=gcc CXX=g++ LDFLAGS=-R$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH ./configure --without-dtrace --no-ifaddrs --prefix=$NROOT

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake install

v6

This is similar to v4. Apply similar fixes to the files deps/v8/src/allocation.cc (posix_memalign) and deps/uv/src/unix/fs.c (mkdtemp) as were necessary in 0.12. There's one additional fix regarding execinfo that appeared at about 6.3, see below.

Very recent versions of v6 have a call to strnlen in deps/uv/src/unix/getaddrinfo.c - replace this with strlen and remove the 2nd argument.

gsed -i 's:-lnsl:-lsocket -lnsl -lrt:' deps/v8/tools/gyp/v8.gyp
gsed -i s:objdump:gobjdump: tools/genv8constants.py
gsed -i 's:define HAVE_EXECINFO_H 1:define HAVE_EXECINFO_H 0:' src/backtrace_posix.cc

env CC=gcc CXX=g++ LDFLAGS=-R$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH ./configure --without-dtrace --no-ifaddrs --prefix=$NROOT

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake install

v8

This is similar to v6. Apply similar fixes to the files deps/v8/src/allocation.cc (posix_memalign) and deps/uv/src/unix/fs.c (mkdtemp) as were necessary in 0.12. There are two fixes regarding execinfo below.

Very recent versions of v8 have a call to strnlen in deps/uv/src/unix/getaddrinfo.c - replace this with strlen and remove the 2nd argument.

gsed -i s:objdump:gobjdump: tools/genv8constants.py
gsed -i 's:define HAVE_EXECINFO_H 1:define HAVE_EXECINFO_H 0:' src/backtrace_posix.cc
gsed -i 's:define HAVE_EXECINFO_H 1:define HAVE_EXECINFO_H 0:' deps/v8/src/base/debug/stack_trace_posix.cc

env CC=gcc CXX=g++ LDFLAGS=-R$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH ./configure --without-dtrace --no-ifaddrs --prefix=$NROOT

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake

env CC=gcc CXX=g++ LD_RUN_PATH=$NROOT/lib LD_LIBRARY_PATH=$NROOT/lib PATH=$GROOT/bin:/usr/bin:$PATH gmake install

All versions

Depending on how you have your gcc installation configured, you'll probably have to copy libstdc++.so.6 and libgcc_s.so.1 from $GROOT/lib into $NROOT/lib.

64-bit support

If you need 64-bit support (my packages are 32-bit which will work on both 32-bit and 64-bit systems), then add --dest-cpu=x64 to the configure command.

Common additions

In order to make the package functional, and for npm to work, I also install a copy of cURL (you may find that 7.42.1 is the latest that will work out of the box on Solaris 10), and add symlinks for tar and make:

ln -s /usr/sfw/bin/gtar $NROOT/bin/tar
ln -s /usr/sfw/bin/gmake $NROOT/bin/make

If you've already got your environment set up, these may not be necessary.


While it's now ancient and no longer relevant, a couple of blog entries described my early attempts to get node running on Solaris. For details see blog entry 1 and blog entry 2.


Peter's Home | Zone Home