EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled
This replicates mesa's egl.pc behavior and fixes build issues on systems without X11.
Merge request reports
Activity
added 1 commit
- de092364 - EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled
added 1 commit
- 13e12161 - EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled
This question came up a while ago in in #206 (closed). I still think adding EGL_NO_X11 to libglvnd's egl.pc is a crude workaround.
Disabling X11 in libglvnd's build options only removes the Xlib platform-guessing code in
eglGetProcAddress
-- it does not disable X11 support for applications. An application can still use X11 by callingeglGetPlatformDisplay
withEGL_PLATFORM_X11_KHR
.If an application needs to build against EGL and doesn't need to use X11, then the application should define EGL_NO_X11.
Alternately, eglplatform.h should be modified upstream to remove the Xlib headers, or at least to make the non-Xlib typedefs the default. I'm pretty sure that doing so could not break any existing builds.
In either case, conditionally setting EGL_NO_X11 in libglvnd isn't the right fix.
Well… without that change:
- libGLVND's EGL effectively ends up pulling X11 as a header-dependency even thought it was explicitly disabled or just isn't present
- Packagers end up forever having to send patches to apps or workaround in their build recipes to fix build issues or pray that changing the defaults on
<EGL/eglplatform.h>
won't break things, which I quite doubt given the differences in the typing
As for avoiding the X11 headers, just removing the include breaks code and you can't copy the definition of the
Display
type over as it's implementation-defined,<X11/Xlib.h>
:/* * Display datatype maintaining display specific data. * The contents of this structure are implementation dependent. * A Display should be treated as opaque by application code. */ #ifndef XLIB_ILLEGAL_ACCESS typedef struct _XDisplay Display; #endif
Edited by Haelwenn MonnierFixing eglplatform.h would just mean making the EGL_NO_X11 path the default, so that you end up with this:
typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType;
Changing EGLNativeDisplayType like that should be fine, because you can still pass
Display*
as thevoid*
parameter of eglGetDisplay without a cast.The EGLNativePixmapType and EGLNativeWindowType typedefs don't change at all, because
XID
andkhronos_uintptr_t
are both typedefs ofunsigned long
.FWIW, libglvnd gets
eglplatform.h
from https://github.com/KhronosGroup/EGL-Registry/blob/master/api/EGL/eglplatform.hI just submitted a pull request make the EGL_NO_X11 version the default in eglplatform.h:
Closing this one, since !248 (merged) has the updated EGL headers.