GMP work on symbol visibility

Richard Biener rguenther at suse.de
Thu Sep 1 07:28:34 UTC 2016


On Wed, 31 Aug 2016, Torbjörn Granlund wrote:

> I am (finally!) resuming work on symbol visibility for libgmp.so.  This
> means that internal references will no longer be indirect through PLT or
> GOT, allowing the shared library to run as fast as the static library.

Great!  (maybe also add symbol versions at the same time?)

> There are several complex issues I need to understand and resolve.  One
> issue is how to handle (unit) testing of hidden functions.  I will
> probably resolve that with alias symbols such as foo_for_testing as an
> alias for foo.

I think unit-testing of internal functions should not be using the
public libgmp.so but a unit-testing convenience library (or for
convenience, simply the static libgmp).

> Another issue is with libgmpxx.so and its dependency on libgmp.so.  As
> separate shared libs, hidden symbols of libgmp.so will not be reachable
> from libgmpxx.so, which of course means we cannot hide them.  Also,
> there will be no performance wins for any libgmpxx.so references to
> libgmp.so.
>
> I see two solutions:
> 
> (1) If we really want to discourage external use, arrange an alias to
> something wierd, making libgmpxx reach the symbol foo as fuckhead_foo.

glibc uses sth like symbol at GLIBC_PRIVATE, thus assign a special
symver to such symbols people could check against.

> (2) Put (allmost) all of libgmp.so in libgmpxx.so.  This gives the best
> performance.

(3) Re-design the C++ interface to only use public parts of the API
(I have no idea and did not check where/why it uses private parts)

(4) Make the private parts the C++ interface uses public

I do not like (2) very much and prefer (3)/(4) over (1).  But if it
has to be then go with (1).

libgmpxx.so is really quite small -- can the C++ wrapper implementation
be changed in a way to only need some additional helpers in the C
libgmp.so and make it otherwise header-only?  Thus drop libgmpxx.so
entirely?

Thanks,
Richard.

> I am interested in your feedback.
> 
> 

-- 
Richard Biener <rguenther at suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)


More information about the gmp-devel mailing list