Compile / install 4.3.2 nodejs

I had some trouble recently trying to compile nodejs under Slackware 14 and I would like to share some notes about it,  just in case someone gets stuck in the same situation.

First of all: there is a precompiled package that should work, so why all the hassle?

Well, I like to compile my own packages. I use Slackware, we don’t have a package manager, we should be able to compile our software ourselves.

Second: slackbuilds can help you

slackbuilds.org has a build script for nodejs 4.2.4 If you are familiar with Slackware, for sure you know what to do with it. But there are three little problems;

  • I want nodejs 4.3.2 and the script is for 4.2.4
  • I am using Slackware 14, not 14.1
  • nodejs wont compile, any version of it

So, I download the script and the 4.3.2 sources, take a peek at nodejs.Slackbuild and modified it to compile the new version:

VERSION=${VERSION:-v4.3.2} #4.2.4

Let’s try it, it’s just a minor version change, it probably works… errr… no. During config, a message alerts that

WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)

Damn, Slackware 14 g++ is 4.7.1 !!  I don’t want to update gcc! It is A LOT of trouble! What if I just …

Third: use an alternative version of gcc / g++

Hmm… so install a newer version, tell configure and make that we want to compile using it… that can’t be so difficult.

I will install gcc and g++ from the oficial distro repos. Yes, I know what I said about “compiling my own software”, but NO, I am not compiling gcc. In the distro I trust.

So, get them from here and here and

# mkdir /opt/gcc
# installpkg --root /opt/gcc ./gcc-4.8.2-i486-1.txz
# installpkg --root /opt/gcc ./gcc-g++-4.8.2-i486-1.txz

Now just tell the script to use it.  Let’s add at the beggining of nodejs.Slackbuild

PATH=/opt/gcc/usr/bin:$PATH
export PATH=/opt/gcc/usr/lib/gcc/i486-slackware-linux/4.8.2:$PATH
export CC=/opt/gcc/usr/bin/cc
export CXX=/opt/gcc/usr/bin/g++

This must work now… and… and… NO!

Fourth: assembler error???

Compiling fails saying

{entrada estándar}: Mensajes del ensamblador:
{entrada estándar}:32423: Error: se espera una instrucción de cadena después de `rep'
make[1]: *** [/tmp/MKp/node-v4.3.2/out/Release/obj.target/v8_base/deps/v8/src/api.o] Error 1

After some thinking and testing, I finally realize that the “-march=xxx -mtune=xxx”  options are to blame. How? well, I just tried to compile the source without the build script, and suddenly I realized that what g++ was saying that there was something rotten when translating to assembler if I tried the default slackbuild options, but everything was fabulous when saying just “./.configure;make”

So, I add a new line to the build script, just under the $SLKCFLAGS assignment to override it

SLKCFLAGS="-O2 -pipe"

And… HEY, KNOW WHAT? IT WORKS!

Final thoughts

So, after some wrestling with the bloody nodejs, looks like it doesn’t like how my computer is arch-tuning it… I don’t know if mine is the only case, but for sure this took me some time to solve, so here it is for your compiling pleasure.

Next, I think I will dig into Slackware’s installpkg script, as I can’t find the new gcc/g++ listed under /var/log/packages and I don’t know why…

This entry was posted in GNU / linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*