_PUBLIC_ in installed tdb/talloc headers used by Samba build

Michael Tokarev mjt at tls.msk.ru
Mon Mar 28 05:41:45 UTC 2022


28.03.2022 02:57, Andrew Bartlett via samba-technical wrote:

Thank you Andrew for stepping in!

> On Sat, 2022-03-26 at 18:22 +0300, Michael Tokarev wrote:
>> I got it finally. 3 days (but with only minor work ;) )
>>
>> tdb.h, talloc.h etc now has _PUBLIC_ definition near every
>> symbol they declare.  By default it defines to something
>> reasonable. But samba defines it to attribute(visibility(hidden)).
>> Which does not work when *importing* these symbols from a
>> shared library..
>>
>> I think we'll have to patch tdb.h to remove these _PUBLIC_
>> marks. Or else it will be difficult to deal with.
>>
>> This happened in the few latest versions of samba.
> 
> I think this might mean we need to extend the work to pre-process these
> files before we install them.  See
> buildtools/wafsamba/samba_headers.py.

I'm not sure this will be entirely sufficient.
It might be fine right now though.

Where it might be bad is when we'll try to build any
additional library, say libldb, from samba sources.
If that lib needs these _PUBLIC_ defines too, _that_
"PUBLIC" needs to be different from PUBLIC used in
the headers of _internal_ libs.

This is why I used GSSAPI_PUBLIC markers as an example.
There should be not just _PUBLIC_ (which must be stripped
out at install time), but something like LIBTDB_PUBLIC,
which is defined differently if we're building libtdb
as a shared library or internal static lib.

> The original work was justified as:
> 
> commit aacd3ecb45ab04cb2f8a38a385a45bdca6d88cd2
> commit 3c1013caf4b57c6af5a5d210df232c08a1227a17

Yeah I've seen these commits. After realizing where
the puzzling ld behavior comes from, I grepped the
history for this _PUBLIC_ definition and come across
these patches and the rationale. We're lucky that
gcc does not impose the same restrictions as the
Solaris Studio compiler so we can hack our way
at install time :)

Thanks!

/mjt



More information about the samba-technical mailing list