1

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

0

3 Answers 3

1

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.)

2
  • Ben, thanks for this answer I hope that @Sarge will come back and change his acceptance to this one. Please put your contact details in your profile as we actively discourage them being added to answers.
    – user9517
    Jul 9, 2011 at 21:53
  • @Ben: Thanks for the reply - that was the clue I was looking for. Unfortunately, I have no more time to spend on the spike that required this so I can't formally test the answer. However, I will certainly accept it. Many thanks.
    – Sarge
    Jul 12, 2011 at 23:22
1

Did you export CC after defining it ?

CC=/usr/sfw/bin/gcc
export CC

Then run your mkmf stuff.

Edit - hacky - create a link

mkdir -p /opt/SUNWspro/bin/
ln -s /usr/sfw/bin/gcc /opt/SUNWspro/bin/cc

Note I also 'fixed' the path in the CC= above as gcc lives in /usr/sfw now.

3
  • Thanks for the reply. I had used export CC=gcc with no change. Doing it in two steps and including the path makes no change to this behaviour.
    – Sarge
    Jul 6, 2011 at 18:57
  • @Sarge: I just noticed that gcc is in /usr/sfw and not /opt/sfw as I originally said. Also you could try the link.
    – user9517
    Jul 6, 2011 at 19:36
  • Thanks for that - I really should have thought of the symlink idea but was thinking about configuration from the top end. It did work in that gcc was executed. Unfortunately, mkmf uses SUN cc only options that don't work with gcc (namely arch=386) so I'll have to use SUN cc. Thanks for your help!
    – Sarge
    Jul 6, 2011 at 20:55
0

Edit the Makefile and modified the CC variable to your gcc binary, then try again.

Is there a ./configure step? If so, you can try setting CC env variable before running it.

1
  • Thanks for the reply. If I edit the Makefile then it just gets overwritten on the next run. There's no configure step. This is ruby code controlling everything.
    – Sarge
    Jul 6, 2011 at 18:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .