[waffle] Update on "Don't explicitly link to libraries - use libdl instead"

Chad Versace chad.versace at intel.com
Tue Feb 17 11:34:54 PST 2015


On 02/12/2015 05:56 AM, Emil Velikov wrote:
> Hello all,
> 
> In case you've been wondering what happened with that here it goes:
> 
> Currently the following libraries could be nuked
> 
>   NEEDED               libwayland-client.so.0
>   NEEDED               libwayland-egl.so.1
>   NEEDED               libX11-xcb.so.1
>   NEEDED               libX11.so.6
>   NEEDED               libxcb.so.1
>   NEEDED               libudev.so.1
> 
> From the above we're using the following problematic APIs:
> 
> X11/xcb
> * XGetXCBConnection
> 
> libwayland-client
> * wl_registry_add_listener
> * wl_shell_surface_add_listener
> * Others ?
> 
> On the X11/xcb side we can fix this by transitioning to a xcb only
> implementation, but that means (a) breaking the API/ABI and (b)
> updating all the users (with XLookupString being the messiest).

We shouldn't break Waffle's X11 API. If you want to expose an XCB-only
backend, then it would make sense to add a new platform type,
WAFFLE_PLATFORM_XCB_EGL, which shares most of its code with
WAFFLE_PLATFORM_X11_EGL.

Is there any reason why Waffle can't use dlsym() to get XGetXCBConnection?
 
> Why problematic - the functions are defined as "static inline" within
> the respective headers, which means that they are expanded during
> compilation. My biggest concern is that (imho) there is no guarantee
> by either library that the current implementation will stay the same,
> thus we cannot manually inline them in waffle.
> 
> Should be bite the bullet and do it anyway ? Does anyone know a lovely
> trick to resolve this ?

There is an easy way to dlsym() the Wayland functions. The inline protocol functions
in wayland-client-protocol.h are all implemented by real library calls to wl_proxy_* functions.
The wl_proxy functions *do* have stable ABI. So, to stop linking to libwayland-client,
for each wl_proxy function used by wayland-client-protocol.h (there's about a dozen),
Waffle needs to provide its own definition of the wl_proxy function that forwards its
arguments to a dlysm() wl_proxy function. Like this:

void
wl_proxy_add_dispatcher(struct wl_proxy *proxy, wl_dispatcher_func_t dispatcher_func,
                        const void *dispatcher_data, void *data)
{
    // This is a function pointer dlsym'd during waffle_init().
    wfl_wl_proxy_add_dispatcher(prox, dispatcher_func, dispatcher_data, data);
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/waffle/attachments/20150217/3d948017/attachment.sig>


More information about the waffle mailing list