Skip to content

Commit

Permalink
Avoid depending on libwayland 1.20 unnecessarily
Browse files Browse the repository at this point in the history
When linking to Wayland libraries in the normal way instead of loading
them dynamically at runtime, listing symbols that don't exist in the
current version results in a build failure.

Most of these symbols are things we call directly, so we want to have
them available as often as possible. However, we don't actually call
wl_proxy_marshal_flags() or wl_proxy_marshal_array_flags() directly.
The reason we need them is that they're called by the code generated
by wayland-scanner >= 1.20.

If we're building with an older Wayland library, then we'll presumably
have its corresponding version of wayland-scanner, so we won't need
those two symbols, and can avoid generating a dependency on them.

libwayland 1.18 is in several LTS distributions (Ubuntu 20.04,
Debian 11, RHEL 8) so avoiding a hard dependency on 1.20 is quite
useful.

Signed-off-by: Simon McVittie <[email protected]>
Resolves: libsdl-org#5376
  • Loading branch information
smcv committed Mar 23, 2022
1 parent f5a9804 commit ac9816b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/video/wayland/SDL_waylanddyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ enum libdecor_window_state;
#include "xkbcommon/xkbcommon.h"
#include "xkbcommon/xkbcommon-compose.h"

/* Must be included before our #defines, see Bugzilla #4957 */
#include "wayland-client-core.h"

#define SDL_WAYLAND_CHECK_VERSION(x, y, z) \
(WAYLAND_VERSION_MAJOR > x || \
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && WAYLAND_VERSION_MICRO >= z))

#ifdef __cplusplus
extern "C"
{
Expand All @@ -71,9 +79,6 @@ void SDL_WAYLAND_UnloadSymbols(void);
}
#endif

/* Must be included before our #defines, see Bugzilla #4957 */
#include "wayland-client-core.h"

#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC

#if defined(_WAYLAND_CLIENT_H) || defined(WAYLAND_CLIENT_H)
Expand Down
2 changes: 2 additions & 0 deletions src/video/wayland/SDL_waylandsym.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_18)
SDL_WAYLAND_SYM(void, wl_proxy_set_tag, (struct wl_proxy *, const char * const *))
SDL_WAYLAND_SYM(const char * const *, wl_proxy_get_tag, (struct wl_proxy *))

#if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC) || SDL_WAYLAND_CHECK_VERSION(1, 20, 0)
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_20)
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interfac, uint32_t version, uint32_t flags, ...))
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_array_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, union wl_argument *args))
#endif

SDL_WAYLAND_INTERFACE(wl_seat_interface)
SDL_WAYLAND_INTERFACE(wl_surface_interface)
Expand Down

0 comments on commit ac9816b

Please sign in to comment.