[libvirt] namespace clean shared libraries

Wido den Hollander wido at widodh.nl
Thu Aug 2 13:14:27 UTC 2012


On 08/02/2012 01:37 PM, Daniel P. Berrange wrote:
> On Thu, Aug 02, 2012 at 01:18:12PM +0200, Wido den Hollander wrote:
>> On 07/08/2012 07:51 PM, Bruno Haible wrote:
>>> Daniel P. Berrange wrote:
>>>> If its better to just do it in libvirt config.h, then we
>>>> can do that too
>>>
>>> Yes, doing '#define foo libvirt_foo' in config.h is the preferred way
>>> of achieving a namespace clean shared library.
>>>
>>> There are two ways to generate these #defines:
>>>
>>> 1) You collect manually, on various systems, the set of symbols that you
>>>     don't want to clash with symbols from other shared libraries. You need
>>>     to do this on various systems, because gnulib may define functions
>>>     'rpl_fflush' or 'dprintf' on some systems and not on others.
>>>
>>> 2) You collect, from a set of header files, the set of symbols that you
>>>     want to have exported, and process all other symbols with
>>>       '#define foo libvirt_foo'
>>>
>>>     This approach is more robust, but requires to compile all *.o files
>>>     twice: Once with the initial settings (no #define), and once for real.
>>>
>>>     This approach is implemented in libunistring. Look at the config.h rule
>>>     in this Makefile.am [1]. There are two auxiliary scripts: 'declared.sh' [2]
>>>     extracts the symbols from a .h file (assuming a particular coding style).
>>>     'exported.sh' [3] extracts te symbols of a .o file.
>>>
>>
>> I don't want to rush anything, but I see that libvirt 0.10 will be
>> coming out soon and I don't think this has been corrected?
>>
>> Right now this means that libvirt is not usable on Ubuntu 12.04
>> systems when you want to use the secrets of libvirt.
>>
>> Is it feasible to have this fixed before 0.10 comes out?
>
> Try applying this patch to your source tree
>
> diff --git a/configure.ac b/configure.ac
> index 6b189db..4f906bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2876,6 +2876,10 @@ test "x$lv_cv_static_analysis" = xyes && t=1
>   AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
>     [Define to 1 when performing static analysis.])
>
> +AC_DEFINE_UNQUOTED([isbase64],[gnulib_isbase64],[Hack to avoid symbol clash])
> +AC_DEFINE_UNQUOTED([base64_encode],[gnulib_base64_encode],[Hack to avoid symbol clash])
> +AC_DEFINE_UNQUOTED([base64_encode_alloc],[gnulib_base64_encode_alloc],[Hack to avoid symbol clash])
> +
>   AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
>            docs/schemas/Makefile \
>            gnulib/lib/Makefile \

Yes, that works for me. The secrets are working on Ubuntu 12.04.

Thanks,

Wido

>
>
> Regards,
> Daniel
>




More information about the libvir-list mailing list