| Summary: | kwayland 5.103.0 fails to compile with LTO enabled due to ODR violations and lto type mismatch | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] kwayland | Reporter: | kostadinshishmanov |
| Component: | general | Assignee: | Martin Flöser <mgraesslin> |
| Status: | REPORTED --- | ||
| Severity: | normal | CC: | bugs.kde.org, kwin-bugs-null, sam |
| Priority: | NOR | ||
| Version First Reported In: | 5.93.0 | ||
| Target Milestone: | --- | ||
| Platform: | Gentoo Packages | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | full build log | ||
Downstream bug report: https://bugs.gentoo.org/866575 This UB is still present with 5.93.0:
[ 70%] Linking CXX shared library ../../bin/libKWaylandClient.so
/home/kostadin/kwayland/src/client/buffer_p.h:17:29: warning: type ‘struct Private’ violates the C++ One Definition Rule [-Wodr]
17 | class Q_DECL_HIDDEN Buffer::Private
| ^
/home/kostadin/kwayland/src/client/buffer_p.h:17:29: note: a different type is defined in another translation unit
17 | class Q_DECL_HIDDEN Buffer::Private
| ^
/home/kostadin/kwayland/src/client/buffer_p.h:25:50: note: the first difference of corresponding definitions is field ‘nativeBuffer’
25 | WaylandPointer<wl_buffer, wl_buffer_destroy> nativeBuffer;
| ^
/home/kostadin/kwayland/src/client/buffer_p.h:25:50: note: a field of same name but different type is defined in another translation unit
25 | WaylandPointer<wl_buffer, wl_buffer_destroy> nativeBuffer;
| ^
/home/kostadin/kwayland/src/client/wayland_pointer_p.h:16:7: note: type ‘struct WaylandPointer’ defined in anonymous namespace cannot match across the translation unit boundary
16 | class WaylandPointer
| ^
/home/kostadin/kwayland/src/client/surface_p.h:18:30: warning: type ‘struct Private’ violates the C++ One Definition Rule [-Wodr]
18 | class Q_DECL_HIDDEN Surface::Private
| ^
/home/kostadin/kwayland/src/client/surface_p.h:18:30: note: a different type is defined in another translation unit
18 | class Q_DECL_HIDDEN Surface::Private
| ^
/home/kostadin/kwayland/src/client/surface_p.h:24:52: note: the first difference of corresponding definitions is field ‘surface’
24 | WaylandPointer<wl_surface, wl_surface_destroy> surface;
| ^
/home/kostadin/kwayland/src/client/surface_p.h:24:52: note: a field of same name but different type is defined in another translation unit
24 | WaylandPointer<wl_surface, wl_surface_destroy> surface;
| ^
/home/kostadin/kwayland/src/client/wayland_pointer_p.h:16:7: note: type ‘struct WaylandPointer’ defined in anonymous namespace cannot match across the translation unit boundary
16 | class WaylandPointer
| ^
/home/kostadin/kwayland/src/client/buffer_p.h:22:10: warning: type of ‘destroy’ does not match original declaration [-Wlto-type-mismatch]
22 | void destroy();
| ^
/home/kostadin/kwayland/src/client/buffer.cpp:41:6: note: ‘destroy’ was previously declared here
41 | void Buffer::Private::destroy()
| ^
/home/kostadin/kwayland/src/client/buffer.cpp:41:6: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
|
Created attachment 156958 [details] full build log SUMMARY kwayland 5.103.0 fails to compile when building with -flto -Werror=odr and -Werror=lto-type-mismatch on Gentoo using gcc 12.2.1 /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer_p.h:17:29: error: type ‘struct Private’ violates the C++ One Definition Rule [-Werror=odr] 17 | class Q_DECL_HIDDEN Buffer::Private | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer_p.h:17:29: note: a different type is defined in another translation unit 17 | class Q_DECL_HIDDEN Buffer::Private | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer_p.h:25:50: note: the first difference of corresponding definitions is field ‘nativeBuffer’ 25 | WaylandPointer<wl_buffer, wl_buffer_destroy> nativeBuffer; | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer_p.h:25:50: note: a field of same name but different type is defined in another translation unit 25 | WaylandPointer<wl_buffer, wl_buffer_destroy> nativeBuffer; | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/wayland_pointer_p.h:16:7: note: type ‘struct WaylandPointer’ defined in anonymous namespace cannot match across the translation unit boundary 16 | class WaylandPointer | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/surface_p.h:18:30: error: type ‘struct Private’ violates the C++ One Definition Rule [-Werror=odr] 18 | class Q_DECL_HIDDEN Surface::Private | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/surface_p.h:18:30: note: a different type is defined in another translation unit 18 | class Q_DECL_HIDDEN Surface::Private | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/surface_p.h:24:52: note: the first difference of corresponding definitions is field ‘surface’ 24 | WaylandPointer<wl_surface, wl_surface_destroy> surface; | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/surface_p.h:24:52: note: a field of same name but different type is defined in another translation unit 24 | WaylandPointer<wl_surface, wl_surface_destroy> surface; | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/wayland_pointer_p.h:16:7: note: type ‘struct WaylandPointer’ defined in anonymous namespace cannot match across the translation unit boundary 16 | class WaylandPointer | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer_p.h:22:10: error: type of ‘destroy’ does not match original declaration [-Werror=lto-type-mismatch] 22 | void destroy(); | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer.cpp:41:6: note: ‘destroy’ was previously declared here 41 | void Buffer::Private::destroy() | ^ /var/tmp/portage/kde-frameworks/kwayland-5.103.0/work/kwayland-5.103.0/src/client/buffer.cpp:41:6: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used lto1: some warnings being treated as errors lto-wrapper: fatal error: /usr/sbin/x86_64-pc-linux-gnu-g++ returned 1 exit status compilation terminated. STEPS TO REPRODUCE 1. add -flto -Werror=odr -Werror=lto-type-mismatch to CFLAGS and CXXFLAGS 2. Try to build 3. Build failure