Building A 64-bit Resin On Solaris 10 Using SunStudio 12u1

This has been bothering me for quite some time. Resin is one of the best application servers I’ve come across. But to get the best performance out of it, you need to recompile it for your platform. While this is no problem on Linux it never quite worked out on Solaris for me when using SunStudio 12. But now I finally made it happen. Here’s how.

First off I have to tell you that this by no means are step-by-step instructions. Think of it as a guideline. To build the 64-bit version of Resin I used this configure command:

  ./configure   --prefix=/opt/resin \
                --enable-64bit \
                --enable-jni \
                --enable-ssl \
                --with-apxs=/opt/apache/bin/apxs \
                --with-openssl-include=/opt/mylibs/include \

Two things to note here: As you can see I also built custom versions of Apache and the OpenSSL libraries. This is done to again benefit from the performance boost the SunStudio compiler suite gives you. For OpenSSL you may end up with a speed increase between 300 and 900%. Not bad, I’d say.

To successfully compile you also need to set some environment variables for the SunStudio compiler suite:

export CFLAGS="-fast -xtarget=${XTARGET} -xarch=${XARCH}-m64 -mt -R/opt/mylib/lib/64 -I/opt/mylib/include"
  export CPPFLAGS="-fast -xtarget=${XTARGET} -xarch=${XARCH} -m64 -mt -R/opt/mylib/lib/64 -I/opt/mylib/include"
  export CXXFLAGS="-fast -xtarget=${XTARGET} -xarch=${XARCH} -m64 -mt -R/opt/mylib/lib/64} -I/opt/mylib/include"
  export LDFLAGS="-fast -xtarget=${XTARGET} -xarch=${XARCH} -m64 -mt -R/opt/mylib/lib/64 -I/opt/mylib/include"

You should set the XTARGET and XARCH variables to the optimum settings for your hardware.

Now before you can run the configure command you need to patch the script itself. The reason for that is that on Solaris the configure script will force the CPU flag on the compiler’s command line to “v9” fpr Sparc CPUs – no matter whether you’re really on Sparc hardware or not. So on x86 systems run

sed -e 's# -xarch=v9##g' configure > configure.patched
mv configure
mv configure.patched configure

Since the xarch flag is already set in the environment variables it doesn’t matter that we’re going to remove it completely here.

Now it’s time to run our new configure command. But refrain from running make just now. Before you can do that you will need to patch the various Makefiles that got generated during configure’s run. This command did the trick for me:

find . -name "Makefile" | xargs -n1 gsed -i "s#-shared -shared#-G -m64 -mt#;s#LD_SHLIB=/usr/ccs/bin/ld#& -G -m64 -mt -R/opt/mylib/lib/64#g"

Ok, now it’s time to run make && make install ;)


One thought on “Building A 64-bit Resin On Solaris 10 Using SunStudio 12u1

Comments are closed.