Smaller C compiler package for Solaris

Over the course of recent months, I have deployed a number of Ruby applications onto Solaris, many of which use a handful of Gem packages. Most of the Gem packages are written in Ruby but a handful are not (e.g. Mongrel, FastThreads and Hpricot) and require native compilation on the host system (part of the installation process).

In order to complete the installation of these Gem packages, you need some form of C compiler. Ordinarily, I would choose GCC, but because the Ruby binaries (and most of the other supporting software packages) I use (i.e. Solaris Coolstack) were compiled using Sun Studio, using GCC is not really an option. So, instead I have to install Sun Studio.

Now, don’t get me wrong, I’ve nothing against the Sun Studio product per say (actually, it’s a superb product). My problem is rather that, in order to install a basic C compiler on my system, I have to download, unzip, untar and then install from a now enormous 1GB (zipped) file (as of Sun Studio 12). This is a real pain and takes a very, very long time (unzip along takes over 15 minutes due to use of Bunzip2 compression). This is all the more painful (and wasteful) when you consider that the disk space consumed by the installation of just the C compiler is a mere 200MB from this 1GB monster.

What I would like (and have requested) is a reduce-size package that contains a basic C compiler only – one that would be used purely for native compilation of the likes of Ruby Gem packages.

Here’s hoping…

Uninstalling Sun Studio

I recently had reason to upgrade to a newer version of Sun Studio on a Solaris 10 system. I had Studio 11 installed but needed to go to version 12 for better support of natively compiled Ruby Gem packages (e.g. mongrel). However, uninstalling Sun Studio is not the most readily documented thing in the world so, for my own future reference, here is the easiest way to do it:

# cd /var/sadm/prod/com.sun.studio_11
# ./batch_uninstall_all

After this, just follow the on-screen instructions …

Native Ruby Gems require Sun Studio 12 with CoolStack 1.2

A substantial number of Ruby Gem packages are written in Ruby itself and install quite neatly using a simple gem install command. However, a number of Gem packages are partly written in C and require some compilation during installation (e.g. hpricot, fastthread and mongrel). This requires you to have a C compiler on the system where you are installing the packages, which is a real pain, but that’s a gripe for another day.

We recently upgraded to CoolStack 1.2 but when we tried to install the Gem packages above, we ran into trouble when the installer attempted to compile the native code for the package. The compiler (Sun Studio 11) complained about the definition of the NORETURN macro in /opt/coolstack/lib/ruby/1.8/i386-solaris2.10/config.h as follows:

syntax error before or at: __attribute__
warning: old-style declaration or incorrect type for:
__attribute__
warning: syntax error: empty declaration
...
cc: acomp failed for hpricot_scan.c

It turns out that the new version of Ruby (1.8.6) that is included with CoolStack 1.2 contains some GCC-oriented macro definitions that Sun Studio 11 does not support. The solution was to upgrade to Studio 12.

Huge thanks go to Basantk for helping to resolve this.

Solaris CoolStack, Sun Studio and Ruby

If you are using the Solaris CoolStack edition of Ruby (CSKruby) with Sun Studio 11 (SUNWspro) then you may need to make a small change to one of the Ruby configuration files to tell it where Sun Studio is installed. I would have have expected the installer for the Ruby package to detect this but, alas, it does not.

In my case, this problem will only manifested itself when I attempted to install some platform-specific Ruby Gems packages (hpricot, fastthreads, mongrel).
To remedy this problem:

  1. Edit the file /opt/coolstack/lib/ruby/1.8/sparc-solaris2.10/rbconfig.rb
  2. Search for all instances of SUNWspro and change to the correct location
  3. Save the file and repeat your “gem install” command

Building Loadable Modules for Apache on Solaris

We recently installed a version of Sun’s CoolStack software bundle on a SunFire T2000 server running Solaris 10 so that we could use its CoolThreads-optimised version of Apache instead of the regular Apache that came pre-installed on the box (highly recommended by Sun).

However, when we ran the new version of Apache against our configuration, we discovered that it does not include a number of key modules that we require (namely Proxy Balancer). Sun does not provide these in binary format so we had to build them by hand. Fortunately, Apache does provide a convenient tool (apxs) for building modules but unfortunately this requires you to install a Sun compiler, Sun Studio (now free though) which added some extra time to the process.

Anyway, I appreciate that this may not be rocket science to many of you but, despite the many articles already published on this topic, there were still some issues that we hit which were not documented. So, here is how we did it.

  1. Ensure that you have installed the latest version of the CoolStack software (installs to /opt/coolstack)
  2. Download, unpack and install Sun Studio 11 (installs to /opt/SUNWspro)
  3. Be patient, very patient … 600MB download, followed by a long unzip to 1.1GB followed by a long install …
  4. Download, unpack and install the CoolStack Source (installs to /opt/coolstack/src)
  5. Now, as a root user, follow the commands below

# export PATH=/opt/SUNWspro/bin:$PATH
# cd /opt/coolstack/src/httpd-2.2.3/modules/proxy
# /opt/coolstack/apache2/bin/apxs -i -a -c mod_proxy.c proxy_util.c

This will compile the module, copy it to the appropriate directory and update the Apache configuration file for you. If you leave out the proxy_util.c you will get "proxy_lb_worker: symbol not found" errors when you start Apache

# /opt/coolstack/apache2/bin/apxs -i -a -c mod_proxy_balancer.c

Once again, this will compile, copy and deploy the module for you

# /opt/coolstack/apache2/bin/apxs -i -a -c mod_proxy_http.c

If you forget to install this module, Apache will start, but the site will be inaccessible (saying you do not have permissions to view this page). You will also see errors like "proxy: No protocol handler was valid for the URL /" in the Apache error log file for your product.

Best of luck!