Building python 2.6.2 for solaris 9 using Sun Studio 12

in Tech Stuff

I recently wanted a 64bit threaded natively compiled version of python 2.6.2. It needed to run on Solaris 9 and Solaris 10 machines, and I didn’t want any dependencies on any other GNU stuff. Basically, a package that I could throw onto any of my Solaris Sparc machines and have it work.

I had a lot of issues getting this to build so here’s what I did.

First make sure the sun pro cc is on the PATH.

$ export CC="cc -mt -m64 -fast -xarch=sparcvis2 -xarch=native"
$ export CFLAGS="-m64 -fast -xarch=sparcvis2 -xarch=native"
$ export LDFLAGS="-m64"
$ ./configure --prefix=/opt/python --with-threads --without-gcc --disable-ipv6 --without-fpectl

Then, edit the Makefile and find the following variables and set them like this:

# Compiler options
OPT=            -DNDEBUG
BASECFLAGS=

This stops it compiling with the wrong switches.

A bunch of stuff will fail:

Failed to find the necessary bits to build these modules:
_sqlite3           bsddb185           dl
gdbm               imageop            linuxaudiodev
ossaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
_bsddb             _ctypes            _curses
_curses_panel      _hashlib           _multiprocessing
_ssl               _tkinter           readline
sunaudiodev

If any of that is important to you, you’ll need to build 64bit versions of them, and set up the linker to find them, -L/path/to/libdir in LDFLAGS will do the trick.

The resulting python binary is very clean:

        libresolv.so.2 =>        /usr/lib/64/libresolv.so.2
        libsocket.so.1 =>        /usr/lib/64/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/64/libnsl.so.1
        librt.so.1 =>    /usr/lib/64/librt.so.1
        libdl.so.1 =>    /usr/lib/64/libdl.so.1
        libm.so.1 =>     /usr/lib/64/libm.so.1
        libthread.so.1 =>        /usr/lib/64/libthread.so.1
        libc.so.1 =>     /usr/lib/64/libc.so.1
        libmp.so.2 =>    /usr/lib/64/libmp.so.2
        libaio.so.1 =>   /usr/lib/64/libaio.so.1
        libmd5.so.1 =>   /usr/lib/64/libmd5.so.1
        /usr/platform/SUNW,Sun-Fire-V440/lib/sparcv9/libc_psr.so.1
        /usr/platform/SUNW,Sun-Fire-V440/lib/sparcv9/libmd5_psr.so.1

Hopefully this helps someone.

1 Comment

One Comment

  1. This is ueful, Thanks !
    Now this gives me some idea about what do do when you are compiling from scratch.
    I wanted to know how I can upgrade python on Solaris 9.
    The current version is 2.2.3.
    I have never compiled/upgraded anything on Solaris 8-) Seems its time I do.
    Actually need to run dJango & it works on 2.4+
    Thanks for any pointers you might have.

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>