gbm/backend: fix gbm compile without dri

Commit introduces a fix that allows for gbm to be built with an empty
backend. There are situation especially in a Yocto/OE cross compilation
environment where you want to build with an empty backend. The particular
situation is as such:

The mesa-gl recipe is the preferred provider for virtual/libgbm, virtual/libgl,
virtual/mesa, etc... But the x11 DISTRO_FEATURE in'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

Issue should be replicable by setting -Ddri3=disabled and -Dgbm=enabled

Add fix to bypasses compilation issue by excluding gbm dri backend. If
HAVE_DRI || HAVE_DRIX not specified.

Acked-by: David Heidelberg <david.heidelberg@collabora.com>
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
(cherry picked from commit 842ca28465)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20821>
This commit is contained in:
Vincent Davis Jr 2022-12-28 16:28:01 -06:00 committed by Dylan Baker
parent 4edf52da3d
commit 2378cb093d
1 changed files with 4 additions and 0 deletions

View File

@ -42,7 +42,9 @@
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
#define VER_MIN(a, b) ((a) < (b) ? (a) : (b))
#if defined(HAVE_DRI) || defined(HAVE_DRI2) || defined(HAVE_DRI3)
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[] = {
#if defined(HAVE_DRI) || defined(HAVE_DRI2) || defined(HAVE_DRI3)
{ "dri", &gbm_dri_backend },
#endif
};
#define BACKEND_LIB_SUFFIX "_gbm"