[Rd] Using gcc4 visibility features

Prof Brian Ripley
2006-01-05T13:36:15Z

R-devel now makes use of gcc4's visibility features: for an in-depth
account see

http://people.redhat.com/drepper/dsohowto.pdf

(and note there are older versions of that document around).

Consider for example stats.so.  On a gcc4 Linux system this has just three
entry points

gannet% nm -g stats.so | grep " T "
00002720 T R_init_stats
0004a544 T _fini
00001f28 T _init

since the only entry point we need is the symbol registration.  This
results in a smaller DSO and a faster load.  It is only worth doing for
shared objects with many entry points, but this one had 262.

It also gives another reason for the registration of symbols, as this is
the only way I know to hide Fortran entry points (except to hide them all,
which will hide them from .Fortran).  Until recently registration was used
in the standard packages and a handful of others (not including any
recommended packages).  You can copy the way it is done in package stats
(see PKG_* in Makefile.in and init.c).

The next step will be to prune libR.so down to something close to the
documented API (it currently has 1816 exported symbols).

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