On Wed, Jun 02, 2021 at 09:05:26PM +0100, Richard W.M. Jones wrote:
> In plugins we expect the plugin_init function to be exported as well
> as *_debug_* variables.  In the server various nbdkit_* functions
> should be exported.
> 
> If you compile nbdkit with -fvisibility=hidden some of these symbols
> are not exported at all even though the linker script says they should
> be.  This option can be useful as it allows the compiler to generate
> simpler and hence faster code, and it's required for Clang CFI.
> 
> Set the visibility to "default" for all symbols we expect to be
> exported.  In theory this should also be required for all the nbdkit_*
> functions exported by the server, but I found that it is not needed by
> either GCC or Clang.
> ---
>  include/nbdkit-common.h  |  6 +++++-
>  include/nbdkit-filter.h  |  1 +
>  include/nbdkit-plugin.h  |  1 +
>  tests/Makefile.am        |  1 +
>  plugins/ocaml/bindings.c | 26 +++++++++++++-------------
>  plugins/ocaml/plugin.c   | 14 +++++++-------
>  tests/dummy-vddk.c       | 30 ++++++++++++++++--------------
>  7 files changed, 44 insertions(+), 35 deletions(-)
> 
> diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h
> index 51a6264c..f43ebe59 100644
> --- a/include/nbdkit-common.h
> +++ b/include/nbdkit-common.h
> @@ -83,10 +83,14 @@ extern "C" {
>  #define NBDKIT_EXTENT_ZERO    (1<<1) /* Same as NBD_STATE_ZERO */
>  
>  #ifndef WIN32
> -#define NBDKIT_EXTERN_DECL(ret, fn, args) extern ret fn args
> +#define NBDKIT_EXTERN_DECL(ret, fn, args)       \
> +  __attribute__((__visibility__("default")))    \
> +  extern ret fn args
> +#define NBDKIT_DLL_PUBLIC __attribute__((__visibility__("default")))
>  #else
>  #define NBDKIT_EXTERN_DECL(ret, fn, args) \
>    extern __declspec(dllexport) ret fn args
> +#define NBDKIT_DLL_PUBLIC __declspec(dllimport)
>  #endif
>  

Looks reasonable to me.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to