Skip to content
Snippets Groups Projects

EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled

Closed Haelwenn Monnier requested to merge lanodan/libglvnd:bugfix/egl_no_x11 into master

This replicates mesa's egl.pc behavior and fixes build issues on systems without X11.

Bug: https://bugs.webkit.org/show_bug.cgi?id=163483

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • added 1 commit

    • de092364 - EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled

    Compare with previous version

  • added 1 commit

    • 13e12161 - EGL: Add -DEGL_NO_X11 to egl.pc Cflags when X11 is disabled

    Compare with previous version

  • 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 calling eglGetPlatformDisplay with EGL_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 Monnier
  • Fixing 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 the void* parameter of eglGetDisplay without a cast.

    The EGLNativePixmapType and EGLNativeWindowType typedefs don't change at all, because XID and khronos_uintptr_t are both typedefs of unsigned long.

  • Or to put it another way: eglplatform.h only needs the Xlib headers so that it can declare EGLNativeDisplayType to be a typedef of Display*, but that typedef is both incorrect and unnecessary.

  • I just submitted a pull request make the EGL_NO_X11 version the default in eglplatform.h:

    https://github.com/KhronosGroup/EGL-Registry/pull/130

  • Thanks a bunch for doing that, Kyle! Looks like it was merged today.

  • Yup. All that's left now is to update libglvnd's headers. I'll get that ready shortly.

  • Closing this one, since !248 (merged) has the updated EGL headers.

Please register or sign in to reply
Loading