Using gcc instead of SUNWspro cc in ruby mkmf for yajl on Solaris 10

gccrubyrubygemssolaris

How do I get mkmf to use gcc instead of /opt/SUNWspro/bin/cc on Solaris 10?

I am trying to install chef using gem install chef. It is failing with:

Building native extensions.  This could take a while...
ERROR:  Error installing chef:
    ERROR: Failed to build gem native extension.

    /opt/csw/bin/ruby18 extconf.rb
creating Makefile

make
/opt/SUNWspro/bin/cc -I. -I/opt/csw/lib/ruby/1.8/i386-solaris2.9 -I/opt/csw/lib/ruby/1.8 /i386-solaris2.9 -I. -I/opt/csw/include -D_FILE_OFFSET_BITS=64  -KPIC -xO3 -m32 -xarch=386  -KPIC  -Wall -funroll-loops  -c yajl.c
make: /opt/SUNWspro/bin/cc: Command not found
make: *** [yajl.o] Error 127


Gem files will remain installed in /opt/csw/lib/ruby/gems/1.8/gems/yajl-ruby-0.8.2 for inspection.
Results logged to /opt/csw/lib/ruby/gems/1.8/gems/yajl-ruby-0.8.2/ext/yajl/gem_make.out

Examining /opt/csw/lib/ruby/gems/1.8/gems/yajl-ruby-0.8.2/ext/yajl/Makefile gives:

CC = /opt/SUNWspro/bin/cc

Crucially, setting the CC environment variable to gcc does absolutely nothing.

Cross posted from StackOverflow

Best Answer

If your CSWruby package is current (it looks to be since the binary is ruby18), you can use the alternatives mechanism to switch to an rbconfig.rb that is setup to use /opt/csw/gcc4/bin/gcc instead of the sun compiler. If it's not quite current, there was a utility included for a while called cswrbconfig that allowed toggling between compilers. I forget which version of the package I added that too, but the feature has been available for over a year if memory serves.

If you have more questions about CSWruby (or other OpenCSW packages), find the maintainers in #opencsw on freenode irc.

(I'm the OpenCSW ruby maintainer.)

Related Topic