Bug 163483 - WaylandCompositor.cpp should define MESA_EGL_NO_X11_HEADERS
Summary: WaylandCompositor.cpp should define MESA_EGL_NO_X11_HEADERS
Status: RESOLVED MOVED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-15 03:18 PDT by ManDay
Modified: 2021-08-24 00:43 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ManDay 2016-10-15 03:18:28 PDT
eglplatform.h as provided by mesa supports the ability to disable inclusion of X11 headers by #define MESA_EGL_NO_X11_HEADERS - the only reasonable thing to do when compiling without X11 support, because otherwise the compile fails. Though implementation specific for MESA, WK should probably use it until Khronos provides this from upstream.
Comment 1 Haelwenn (lanodan) Monnier 2021-07-24 21:36:22 PDT
<EGL/eglplatform.h> allows to use EGL_NO_X11 for this, which seems less implementation specific.
I think should be defined via adding -DEGL_NO_X11 to the C(XX)FLAGS as without this flag I also get fails on Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp:40 (#include <EGL/egl.h> when USE(LIBEPOXY) is false).
Comment 2 Adrian Perez 2021-07-29 13:09:13 PDT
The correct thing to do here is picking the compiler flags from
the Mesa pkg-config file (mesa.pc) correctly, using the _CFLAGS_OTHER
variable defined by CMake's find_package() command. For example this
was done here:

  https://github.com/WebPlatformForEmbedded/libwpe/pull/4/

Hardcoding a certain -DFOO will not work in all cases because different
drivers may need different compiler options. The suggested options are
Mesa-specific, but will fail for example with the proprietary Vivante
drivers that target Wayland or the framebuffer. Picking the correct
flags from the .pc file should work for all reasonable drivers :)
Comment 3 Haelwenn (lanodan) Monnier 2021-07-29 17:30:45 PDT
Well it sure would be better to use pkg-config files but it doesn't seems to work.

> Mesa pkg-config file (mesa.pc)

I do not have a mesa.pc

[0] $ pkg-config --path mesa
[1] $ qlist mesa | grep mesa.pc
[1] $

> libwpe as example

libwpe is among the packages where I need to add -DEGL_NO_X11 for it to build on my libX11-free setup (gentoo system with USE=-X).

As you seem to hint, maybe the blame of not defining -DEGL_NO_X11 when X is disabled lies on the provider of egl.pc? For me it's libGLVND.
Comment 4 Adrian Perez 2021-07-29 20:18:53 PDT
(In reply to Haelwenn (lanodan) Monnier from comment #3)
> Well it sure would be better to use pkg-config files but it doesn't seems to
> work.
> 
> > Mesa pkg-config file (mesa.pc)
> 
> I do not have a mesa.pc

I was sleepy when I wrote this. I meant “egl.pc”

> [0] $ pkg-config --path mesa
> [1] $ qlist mesa | grep mesa.pc
> [1] $
> 
> > libwpe as example
> 
> libwpe is among the packages where I need to add -DEGL_NO_X11 for it to
> build on my libX11-free setup (gentoo system with USE=-X).
> 
> As you seem to hint, maybe the blame of not defining -DEGL_NO_X11 when X is
> disabled lies on the provider of egl.pc? For me it's libGLVND.

Sounds like libGLVND should include the needed flags in “egl.pc”. 

Using Mesa's (without libGLVND) works as expected; for example I have
a Wayland only Buildroot configuration here right know which contains
this:

  % cat output-rpi3-wpe/staging/usr/lib/pkgconfig/egl.pc   
  prefix=/usr
  libdir=${prefix}/lib
  includedir=${prefix}/include

  Name: egl
  Description: Mesa EGL Library
  Version: 21.1.5
  Requires.private: libdrm >=  2.4.75
  Libs: -L${libdir} -lEGL
  Libs.private: -lpthread -pthread -lm
  Cflags: -I${includedir} -DEGL_NO_X11
  %

I see at https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/egl.pc.in
that libGLVND's “egl.pc.in” template does not put anything in the “Cflags:”
field. Probably nobody thought about it when X11 support was made optional
in libGLVND in https://github.com/NVIDIA/libglvnd/pull/184 😉
Comment 5 Haelwenn (lanodan) Monnier 2021-07-29 23:18:29 PDT
(In reply to Adrian Perez from comment #4)
> Sounds like libGLVND should include the needed flags in “egl.pc”. 

Yeah, sounds reasonable, so I sent https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/246

And a backport for gentoo: https://github.com/gentoo/gentoo/pull/21832/files
Comment 6 Adrian Perez 2021-07-30 13:42:20 PDT
(In reply to Haelwenn (lanodan) Monnier from comment #5)
> (In reply to Adrian Perez from comment #4)
> > Sounds like libGLVND should include the needed flags in “egl.pc”. 
> 
> Yeah, sounds reasonable, so I sent
> https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/246
> 
> And a backport for gentoo: https://github.com/gentoo/gentoo/pull/21832/files

Nice, I subscribed to the PR—I'm curious to see how it goes. I suppose
we could close this bug report, then. How does that sound?
Comment 7 Haelwenn (lanodan) Monnier 2021-08-23 16:00:53 PDT
With the fix being done on Kronos side (not requiring -DEGL_NO_X11 anywhere), I think this bug can be closed.
Comment 8 Adrian Perez 2021-08-24 00:42:58 PDT
(In reply to Haelwenn (lanodan) Monnier from comment #7)
> With the fix being done on Kronos side (not requiring -DEGL_NO_X11
> anywhere), I think this bug can be closed.

Yes, I agree. Thanks for helping pushing the fix in the most suitable
location =)