Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build with drm_backend or sdl2_backend disabled #1347

Open
HanabishiRecca opened this issue Jun 2, 2024 · 4 comments
Open

Unable to build with drm_backend or sdl2_backend disabled #1347

HanabishiRecca opened this issue Jun 2, 2024 · 4 comments

Comments

@HanabishiRecca
Copy link

HanabishiRecca commented Jun 2, 2024

drm_backend and sdl2_backend meson options are effectively useless right now as you can't disable them.

When trying to build with drm_backend=disabled:

[398/424] Compiling C++ object src/gamescope.p/edid.cpp.o
FAILED: src/gamescope.p/edid.cpp.o 
c++ ...
In file included from ../gamescope/src/edid.cpp:5:
../gamescope/src/hdmi.h:28:9: error: ‘__u8’ does not name a type
   28 |         __u8 eotf;
      |         ^~~~
../gamescope/src/hdmi.h:32:9: error: ‘__u8’ does not name a type
   32 |         __u8 metadata_type;
      |         ^~~~
[405/424] Compiling C++ object src/gamescope.p/wlserver.cpp.o
FAILED: src/gamescope.p/wlserver.cpp.o 
c++ ...
In file included from ../gamescope/src/wlserver.cpp:51:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/xf86drm.h:40,
                 from ../gamescope/src/wlserver.cpp:11:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[408/424] Compiling C++ object src/gamescope.p/rendervulkan.cpp.o
FAILED: src/gamescope.p/rendervulkan.cpp.o 
c++ ...
In file included from ../gamescope/src/rendervulkan.cpp:26:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.cpp:25:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[410/424] Compiling C++ object src/gamescope.p/wayland_backend.cpp.o
FAILED: src/gamescope.p/wayland_backend.cpp.o 
c++ ...
In file included from ../gamescope/src/drm_include.h:13,
                 from ../gamescope/src/wayland_backend.cpp:35:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.hpp:75,
                 from ../gamescope/src/wayland_backend.cpp:2:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[412/424] Compiling C++ object src/gamescope.p/steamcompmgr.cpp.o
FAILED: src/gamescope.p/steamcompmgr.cpp.o 
c++ ...
In file included from ../gamescope/src/steamcompmgr.cpp:90:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.hpp:75,
                 from ../gamescope/src/steamcompmgr.cpp:82:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~

When trying to build with sdl2_backend=disabled:

[462/462] Linking target src/gamescope
FAILED: src/gamescope 
c++  ...
/usr/sbin/ld: /tmp/ccxk8uA1.ltrans4.ltrans.o: in function `main':
<artificial>:(.text.startup+0x1e34): undefined reference to `bool gamescope::IBackend::Set<gamescope::CSDLBackend>()'
/usr/sbin/ld: /tmp/ccxk8uA1.ltrans7.ltrans.o: in function `gamescope::CWaylandBackend::PostInit()':
<artificial>:(.text+0x306f): undefined reference to `gamescope::GetX11HostCursor()'
collect2: error: ld returned 1 exit status
@HanabishiRecca
Copy link
Author

HanabishiRecca commented Jun 2, 2024

I tackled the code and looks like it is pretty much impossible to disable libdrm as Wayland backend really depends on it.
So it is easier to just drop drm_backend option at this point. I.e. partially revert 67984a8 and make it a hard dependency again.


As for sdl2_backend, seems easy to fix:

diff --git a/src/main.cpp b/src/main.cpp
index 01dd8ca..3aa0ffc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -834,8 +834,10 @@ int main(int argc, char **argv)
 
 		case gamescope::GamescopeBackend::Wayland:
 			gamescope::IBackend::Set<gamescope::CWaylandBackend>();
+#if HAVE_SDL2
 			if ( !GetBackend() )
 				gamescope::IBackend::Set<gamescope::CSDLBackend>();
+#endif
 			break;
 		default:
 			abort();
diff --git a/src/wayland_backend.cpp b/src/wayland_backend.cpp
index c5b33cf..745cb35 100644
--- a/src/wayland_backend.cpp
+++ b/src/wayland_backend.cpp
@@ -1247,8 +1247,10 @@ namespace gamescope
             return false;
         }
 
+#if HAVE_SDL2
         m_pDefaultCursorInfo = GetX11HostCursor();
         m_pDefaultCursorSurface = CursorInfoToSurface( m_pDefaultCursorInfo );
+#endif
 
         if ( g_bForceRelativeMouse )
             this->SetRelativeMouseMode( true );

@misyltoad
Copy link
Collaborator

There's another backend for platforms not using libdrm that I haven't pushed up yet.

I think GetX11HostCursor should be moved into its own file, then that can be a proper fix for upstream

@HanabishiRecca
Copy link
Author

HanabishiRecca commented Jun 2, 2024

This seems to work. I'm not a C++ guy though, so I maybe did it wrong.

Edit: actually its easier to review it as a PR: #1350.

@HanabishiRecca
Copy link
Author

And another bit of improvement: #1351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants