We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5463

Summary: generated Wayland interfaces are included in the library's ABI
Product: SDL Reporter: Simon McVittie <smcv>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz
Version: 2.0.14   
Hardware: x86_64   
OS: Linux   
Attachments: build: Prefer to use `wayland-scanner private-code`
waylandtouch: Don't export interface structs

Description Simon McVittie 2021-01-13 13:27:32 UTC
If SDL is built with Wayland enabled, the ABI of the library includes generated code for Wayland interfaces. I assume this was not intended to be present? For example:

$ objdump -T -x build/.libs/libSDL2-2.0.so.0
...
0000000000173aa0 g     O .data.rel.ro   0000000000000028              zxdg_shell_v6_interface
...
0000000000172ea0 g     O .data.rel.ro   0000000000000028              wl_data_source_interface
...
0000000000171820 g     O .data.rel.ro   0000000000000028              qt_extended_surface_interface

This seems to be because SDL is using the deprecated form `wayland-scanner code`. In recent versions of wayland-scanner, this produces symbols that are marked with __attribute__((visibility("default")), overriding SDL's -fvisibility=hidden.

A similar report in Qt: https://bugreports.qt.io/browse/QTBUG-73099

I'll attach a patch in a moment.
Comment 1 Simon McVittie 2021-01-13 13:31:06 UTC
Created attachment 4661 [details]
build: Prefer to use `wayland-scanner private-code`

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
Comment 2 Sam Lantinga 2021-01-14 22:50:56 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/0530cf0a871c
Comment 3 Simon McVittie 2021-01-15 17:48:12 UTC
Sorry, I missed some that are included in the C code rather than being generated at build-time.

It would probably be better if they were generated at build-time like the rest, but for now, I'll just take them out of the ABI...
Comment 4 Simon McVittie 2021-01-15 17:49:02 UTC
Created attachment 4665 [details]
waylandtouch: Don't export interface structs

These are explicitly written in C code rather than generated at build
time, so they weren't affected by changing how we invoke
wayland-scanner.
Comment 5 Sam Lantinga 2021-01-23 19:23:35 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/a3d4219798f6