When building Perl modules with CPAN, the system assumes that the same compiler arguments that were used to compile Perl (indicated in the output of "perl -V") should be used to compile modules. However on OpenSolaris, Perl was compiled with the Sun C compiler, whereas the OS distributes GCC by default. This translates to an annoying situation: out of the box, when attempting to build a CPAN module, GCC will fail when encountering arguments CPAN passed to it that it does not recognize (the most prevalent error is "unrecognized option `-KPIC'"). The right solution is of course to install the Sun C compiler ("pkg install ss-dev") but this is 200MB+ of packages with tons of dependencies. A quicker and hackish workaround is to write a cc(1) wrapper that translates or ignores the 4 arguments that GCC does not support (-KPIC -xO3 -xspace -xildoff). I wrote such a wrapper. Put it in a temporary PATH location (eg. /root/bin) and run CPAN like this:
$ env PATH="/root/bin:$PATH" /usr/perl5/5.8.4/bin/cpan Crypt::SSLeay
Here is the code:
#!/usr/bin/python
# cc(1) wrapper to build CPAN Perl modules with GCC on OpenSolaris. -mrb
import os, sys
path = '/usr/gnu/bin/cc'
args = []
i = 0
while i < len(sys.argv):
if i == 0:
args.append(path)
elif sys.argv[i] == '-KPIC':
args.append('-fPIC')
elif sys.argv[i] == '-xO3':
args.append('-O3')
elif sys.argv[i] == '-xspace':
pass
elif sys.argv[i] == '-xildoff':
pass
else:
args.append(sys.argv[i])
i += 1
os.execv(path, args)