Skip to content

Commit

Permalink
kmsdrm: Fix an LTO type mismatch warning
Browse files Browse the repository at this point in the history
Include SDL_kmsdrmopengles.h before SDL_kmsdrmvulkan.h, as the Vulkan header can pull in Wayland headers, which pull in EGL headers with EGL types defined as Wayland types, which causes warnings when building with strict-aliasing and LTO.
  • Loading branch information
Kontrabant committed Dec 4, 2024
1 parent 31128b6 commit 24ed947
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/video/kmsdrm/SDL_kmsdrmvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

#ifdef SDL_VIDEO_DRIVER_KMSDRM

/* Include this before SDL_kmsdrmvulkan.h, as the Vulkan header can pull in
* Wayland headers, which pull in EGL headers with EGL types defined as Wayland
* types, which causes warnings when building with strict-aliasing and LTO.
*/
#include "SDL_kmsdrmopengles.h"

/* include this here before SDL_sysvideo.h to avoid vulkan type
* redefinition errors. it already includes SDL_sysvideo.h. */
#include "SDL_kmsdrmvulkan.h"
Expand All @@ -43,7 +49,6 @@
#include "SDL_kmsdrmevents.h"
#include "SDL_kmsdrmmouse.h"
#include "SDL_kmsdrmvideo.h"
#include "SDL_kmsdrmopengles.h"
#include <dirent.h>
#include <errno.h>
#include <poll.h>
Expand Down

1 comment on commit 24ed947

@sezero
Copy link
Contributor

@sezero sezero commented on 24ed947 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kontrabant : This brought back the type redefinition errors with older gcc versions:

In file included from /tmp/SDL3/src/video/kmsdrm/.././khronos/vulkan/vulkan.h:11,
                 from /tmp/SDL3/src/video/kmsdrm/../SDL_vulkan_internal.h:52,
                 from /tmp/SDL3/src/video/kmsdrm/SDL_kmsdrmvulkan.h:32,
                 from /tmp/SDL3/src/video/kmsdrm/SDL_kmsdrmvideo.c:34:
/tmp/SDL3/src/video/kmsdrm/.././khronos/vulkan/vulkan_core.h:101: error: redefinition of typedef ‘VkInstance’
/tmp/SDL3/include/SDL3/SDL_vulkan.h:67: note: previous declaration of ‘VkInstance’ was here
/tmp/SDL3/src/video/kmsdrm/.././khronos/vulkan/vulkan_core.h:102: error: redefinition of typedef ‘VkPhysicalDevice’
/tmp/SDL3/include/SDL3/SDL_vulkan.h:68: note: previous declaration of ‘VkPhysicalDevice’ was here
In file included from /tmp/SDL3/src/video/kmsdrm/.././khronos/vulkan/vulkan.h:11,
                 from /tmp/SDL3/src/video/kmsdrm/../SDL_vulkan_internal.h:52,
                 from /tmp/SDL3/src/video/kmsdrm/SDL_kmsdrmvulkan.h:32,
                 from /tmp/SDL3/src/video/kmsdrm/SDL_kmsdrmvideo.c:34:
/tmp/SDL3/src/video/kmsdrm/.././khronos/vulkan/vulkan_core.h:7549: error: redefinition of typedef ‘VkSurfaceKHR’
/tmp/SDL3/include/SDL3/SDL_vulkan.h:69: note: previous declaration of ‘VkSurfaceKHR’ was here
make[2]: *** [CMakeFiles/SDL3-shared.dir/src/video/kmsdrm/SDL_kmsdrmvideo.c.o] Error 1

Please sign in to comment.