Fixed bug 5463 - generated Wayland interfaces are included in the library's ABI

Simon McVittie

In versions since 1.15, the `code` mode is a deprecated alias for
`public-code`, which emits symbols with default visibility, overriding
SDL's -fvisibility=hidden option.

Use the `private-code` mode instead. This emits symbols with hidden
visibility, so they do not affect the ABI of libSDL.

See also: https://bugreports.qt.io/browse/QTBUG-73099,
https://lists.freedesktop.org/archives/wayland-devel/2018-February/037097.html
This commit is contained in:
Sam Lantinga 2021-01-14 14:50:15 -08:00
parent 6a342954e8
commit 351abc585b
4 changed files with 72 additions and 5 deletions

View File

@ -43,6 +43,7 @@ SDLTEST_TARGET = libSDL2_test.la
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
WAYLAND_SCANNER = @WAYLAND_SCANNER@
WAYLAND_SCANNER_CODE_MODE = @WAYLAND_SCANNER_CODE_MODE@
INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@

View File

@ -564,7 +564,7 @@ macro(CheckX11)
endif()
endmacro()
macro(WaylandProtocolGen _SCANNER _XML _PROTL)
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")
@ -579,7 +579,7 @@ macro(WaylandProtocolGen _SCANNER _XML _PROTL)
OUTPUT "${_WAYLAND_PROT_C_CODE}"
DEPENDS "${_WAYLAND_PROT_H_CODE}"
COMMAND "${_SCANNER}"
ARGS code "${_XML}" "${_WAYLAND_PROT_C_CODE}"
ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
)
set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}")
@ -594,6 +594,7 @@ endmacro()
macro(CheckWayland)
if(VIDEO_WAYLAND)
pkg_check_modules(WAYLAND wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon)
pkg_check_modules(WAYLAND_SCANNER_1_15 "wayland-scanner>=1.15")
if(WAYLAND_FOUND)
execute_process(
@ -610,6 +611,12 @@ macro(CheckWayland)
endif()
if(WAYLAND_FOUND)
if(WAYLAND_SCANNER_1_15_FOUND)
set(WAYLAND_SCANNER_CODE_MODE "private-code")
else()
set(WAYLAND_SCANNER_CODE_MODE "code")
endif()
link_directories(
${WAYLAND_LIBRARY_DIRS}
)
@ -629,7 +636,7 @@ macro(CheckWayland)
file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml")
foreach(_XML ${WAYLAND_PROTOCOLS_XML})
string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}")
WaylandProtocolGen("${WAYLAND_SCANNER}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}")
endforeach()
if(VIDEO_WAYLAND_QT_TOUCH)

57
configure vendored
View File

@ -630,6 +630,7 @@ ac_includes_default="\
#endif"
ac_subst_vars='LTLIBOBJS
WAYLAND_SCANNER_CODE_MODE
WAYLAND_SCANNER
EXTRA_LDFLAGS
BUILD_LDFLAGS
@ -19793,6 +19794,11 @@ $as_echo_n "checking for Wayland support... " >&6; }
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
if $PKG_CONFIG --exists 'wayland-scanner >= 1.15'; then :
WAYLAND_SCANNER_CODE_MODE=private-code
else
WAYLAND_SCANNER_CODE_MODE=code
fi
video_wayland=yes
fi
fi
@ -22901,6 +22907,47 @@ $as_echo "#define SDL_INPUT_FBSDKBIO 1" >>confdefs.h
fi
}
CheckInputWSCONS()
{
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenBSD wscons" >&5
$as_echo_n "checking for OpenBSD wscons... " >&6; }
use_input_wscons=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsksymdef.h>
#include <dev/wscons/wsksymvar.h>
#include <sys/ioctl.h>
int
main ()
{
struct wskbd_map_data data;
ioctl(0, WSKBDIO_GETMAP, &data);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
use_input_wscons=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_wscons" >&5
$as_echo "$use_input_wscons" >&6; }
if test x$use_input_wscons = xyes; then
$as_echo "#define SDL_INPUT_WSCONS 1" >>confdefs.h
SUMMARY_input="${SUMMARY_input} wscons"
fi
}
CheckLibUDev()
{
# Check whether --enable-libudev was given.
@ -24853,6 +24900,9 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
freebsd)
CheckInputKBIO
;;
openbsd)
CheckInputWSCONS
;;
esac
CheckUSBHID
CheckHIDAPI
@ -25028,6 +25078,11 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_kbd.c"
SOURCES="$SOURCES $srcdir/src/core/freebsd/SDL_evdev_kbd_freebsd.c"
fi
# Set up files for wscons input
if test x$use_input_wscons = xyes; then
SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_kbd.c"
SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_mouse.c"
fi
# Set up other core UNIX files
SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_capabilities.c"
SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
@ -25822,7 +25877,7 @@ if test x$video_wayland = xyes; then
echo ;\
printf '%s\n' "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\
printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) \\$(WAYLAND_SCANNER_CODE_MODE) \\$< \\$@" ;\
echo ;\
printf '%s\n' "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\
printf '%s\n' " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\

View File

@ -1539,6 +1539,9 @@ AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
AS_IF([$PKG_CONFIG --exists 'wayland-scanner >= 1.15'],
[WAYLAND_SCANNER_CODE_MODE=private-code],
[WAYLAND_SCANNER_CODE_MODE=code])
video_wayland=yes
fi
fi
@ -4381,7 +4384,7 @@ if test x$video_wayland = xyes; then
echo ;\
printf '%s\n' "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\
printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) \\$(WAYLAND_SCANNER_CODE_MODE) \\$< \\$@" ;\
echo ;\
printf '%s\n' "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\
printf '%s\n' " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\
@ -4492,6 +4495,7 @@ AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(EXTRA_LDFLAGS)
AC_SUBST(WAYLAND_SCANNER)
AC_SUBST(WAYLAND_SCANNER_CODE_MODE)
cat >Makefile.rules <<__EOF__