new file mode 100644
@@ -0,0 +1,51 @@
+Fix gbm compile without dri
+
+Upstream-Status: Inappropriate
+
+Only required if mesa-gl is the preferred provider
+of virtual/libgl, etc and the x11 DISTRO_FEATURE
+not included.
+
+Patch allows for gbm to be built with an
+empty backend. Thera are situation where mesa-gl
+is the preferred provider for virtual/libgbm,
+virtual/libgl, etc... But the x11 DISTRO_FEATURE
+isn't included this leads to build errors such as
+
+| /../../../ld: src/gbm/libgbm.so.1.0.0.p/main_backend.c.o: in function `find_backend':
+| backend.c:(.text.find_backend+0xa4): undefined reference to `gbm_dri_backend'
+| /../../../ld: src/gbm/libgbm.so.1.0.0.p/main_backend.c.o:(.data.rel.ro.builtin_backends+0x4):
+undefined reference to `gbm_dri_backend'
+| collect2: error: ld returned 1 exit status
+
+Relevant previous mesa bug:
+* https://bugs.freedesktop.org/show_bug.cgi?id=78225
+
+Build libgbm without backend if its known that libgbm
+won't be utilized in OE system image.
+
+Signed-off-by: Vincent Davis Jr <vince@underview.tech>
+Index: mesa-22.2.3/src/gbm/main/backend.c
+===================================================================
+--- mesa-22.2.3.orig/src/gbm/main/backend.c
++++ mesa-22.2.3/src/gbm/main/backend.c
+@@ -42,7 +42,9 @@
+ #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+ #define VER_MIN(a, b) ((a) < (b) ? (a) : (b))
+
++#ifdef HAVE_DRI
+ extern const struct gbm_backend gbm_dri_backend;
++#endif
+
+ struct gbm_backend_desc {
+ const char *name;
+@@ -51,7 +53,9 @@ struct gbm_backend_desc {
+ };
+
+ static const struct gbm_backend_desc builtin_backends[] = {
++#ifdef HAVE_DRI
+ { "dri", &gbm_dri_backend },
++#endif
+ };
+
+ #define BACKEND_LIB_SUFFIX "_gbm"
@@ -6,6 +6,12 @@ PROVIDES = "virtual/libgl virtual/mesa"
S = "${WORKDIR}/mesa-${PV}"
+SRC_URI:append = "\
+ ${@bb.utils.contains('DISTRO_FEATURES', 'x11', '', 'file://0001-undefined-reference-gbm-backend.patch', d)} \
+ "
+
+TARGET_CFLAGS = "-I${STAGING_INCDIR}/drm"
+
# At least one DRI rendering engine is required to build mesa.
# When no X11 is available, use osmesa for the rendering engine.
PACKAGECONFIG ??= "opengl ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', 'osmesa gallium', d)}"
Commit introduces a patch that allows for gbm to be built with an empty backend. There are situation where mesa-gl is the preferred provider for virtual/libgbm, virtual/libgl, virtual/mesa, etc... But the x11 DISTRO_FEATURE isn't included this leads to build errors such as | /../../../ld: src/gbm/libgbm.so.1.0.0.p/main_backend.c.o: in function `find_backend': | backend.c:(.text.find_backend+0xa4): undefined reference to `gbm_dri_backend' | /../../../ld: src/gbm/libgbm.so.1.0.0.p/main_backend.c.o:(.data.rel.ro.builtin_backends+0x4): undefined reference to `gbm_dri_backend' | collect2: error: ld returned 1 exit status Add patch bypasses compilation issue by excluding gbm dri backend. Signed-off-by: Vincent Davis Jr <vince@underview.tech> --- ...0001-undefined-reference-gbm-backend.patch | 51 +++++++++++++++++++ meta/recipes-graphics/mesa/mesa-gl_22.2.3.bb | 6 +++ 2 files changed, 57 insertions(+) create mode 100644 meta/recipes-graphics/mesa/files/0001-undefined-reference-gbm-backend.patch