[R] Building R on Solaris (OpenIndiana) with gcc 4.6.2 for amd64 target - relocation problems solved

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 10 10:15:55 CEST 2012


This was really a topic for R-devel rather than R-help.

It depends on the fine details of your build of gcc.  R's configure sets 
SHLIB_LDFLAGS=-shared for the GNU linker and SHLIB_LDFLAGS=-G for the 
Solaris linker.  That used to work on Opteron and still does on Sparc. 
If the setting is wrong, that is the only variable you need to set for 
configuration to change all the SHLIB_*FLAGS.

It seems that the latest OpenCSW compilers need -shared, but there are 
still relocation problems on amd64 as not all the libraries 
(specifically libjbig) are properly PIC.



On 07/04/2012 11:42, Michael Figiel wrote:
> On 04/ 7/12 08:13 AM, Prof Brian Ripley wrote:
>> On 06/04/2012 19:38, Michael Figiel wrote:
>>> Hello,
>>> the "R Installation and Administration" handbook states in Section C
>>> 5.1:
>>> For ‘amd64’ the builds have failed to complete in several different
>>> ways, currently with relocation errors for libRblas.so.
>>>
>>> To fix it: add '-shared' to the SHLIB_LDFLAGS, SHLIB_CXXLDFLAGS and
>>> SHLIB_FCLDFLAGS before starting configure.
>>>
>>> So the complete set of variables' values sufficient to build for the
>>> amd64 target (as used on OpenIndiana 151a2 with gcc 4.6.2):
>>> SHLIB_LDFLAGS=-shared
>>> SHLIB_CXXFLAGS=-shared
>>> SHLIB_FCLDFLAGS=-shared
>>> CFLAGS=-m64
>>> CXXFLAGS=-m64
>>> FFLAGS=-m64
>>> FCFLAGS=-m64
>>> LDFLAGS=-m64 -L/usr/local/lib/amd64
>>> CPPFLAGS=-I/usr/local/include
>>>
>>> Additionally you'll need the gnu libiconv, which resides probably in
>>> /usr/gnu, so the CPPFLAGS will need an -I/usr/gnu/include and the
>>> LDFLAGS needs a -L/usr/gnu/lib/amd64 (on my machines I keep everything
>>> in /usr/local therefor no reference to /usr/gnu )
>>>
>>> If you prefer to use the Solaris linker (/usr/bin/ld) add
>>> -fno-gnu-linker to the SHLIB_* variables and make sure, your PATH
>>> doesn't list /usr/gnu/bin before /usr/bin.
> I was wrong on that: you don't need to set anything - the gcc
> (pkg:/runtime/gcc at 4.6.2-0.151.1) will always use the Solaris linker. I
> don't know how to force it to use the gnu linker - I think, it's a
> compile time option.
>>>
>>> I've got only OpenIndiana machines, but it should work on Solaris 10/11,
>>> too.
>>
>> Your instructions are for the GNU linker: those in the manual are for
>> the Solaris linker, which does not support --shared.
> Well, the options '-shared' and '-m64' are for the gcc, not for the
> linker. The build process doesn't invoke the linker directly, it's
> always via gcc, which processes the options and takes care for correct
> invocation of the linker. Without '-shared' the gcc invokes ld in a way,
> which makes the resulting shared object position dependent, even if the
> object code was position independent (I haven't investigated what
> actually happens there, I only verified with elfdump -d , that the
> resulting shared object contains text relocations).
>
> Kind regards
> Michael Figiel


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list