Forums » Ruby-core » use -shared to gcc for shared link Solaris

use -shared to gcc for shared link Solaris
Posted by Andrew Morrow (Guest)
on 27.04.2006 15:35
While trying to build a 64 bit ruby from cvs on Solaris 10 x86 with a
recent gcc-4.2 snapshot (configured to use the solaris linker) the
build fails:

making ruby
gmake[1]: Entering directory `/home/acm/ruby/build/targets'
/usr/local/gcc-4.2-20060415/bin/gcc -std=gnu99 -m64  -fPIC
-DRUBY_EXPORT  -std=gnu99 -m64 -R/home/acm/ruby/build/install/lib -L.
 main.o  -lruby -lrt -lpthread -lsocket -ldl -lm   -o ruby
gmake[1]: Leaving directory `/home/acm/ruby/build/targets'
ld.so.1: ruby: fatal: relocation error: R_AMD64_PC32: file
./libruby.so.1: symbol main: value 0x280011941c0 does not fit

This appears to be because the shared link step for libruby was
driven with -Wl,-G instead of -shared:

/usr/local/gcc-4.2-20060415/bin/gcc -Wl,-G -std=gnu99 -m64
-Wl,-h,libruby.so.1 <list-of-files> -lrt -lpthread -lsocket -ldl -lm
 -o libruby.so.1

gcc wants to know that this is a shared link, not just the linker, and
changing the shared link command LDSHARED from '$CC -Wl,-G' to '$CC
-shared' in configure.in fixes the problem.

The attached patch unconditionally sets LDSHARED to '$CC -shared' when
using gcc on Solaris, instead of only using -shared when GNU ld is
detected.

Thanks,
Andrew