From 63f24224752cb87f3dbac0a4147b4ae855ae3c21 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sun, 14 Dec 2025 01:25:14 +0200 Subject: [PATCH] glx: include: meson_options.txt: Allow disabling DRI glx backends This allows building the X server with glx and without mesa. This also makes the X server optionally no longer be a loader for dri drivers. Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1638 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1819 Signed-off-by: stefan11111 --- glx/{ => glx_dri}/glxdri2.c | 0 glx/{ => glx_dri}/glxdricommon.c | 0 glx/{ => glx_dri}/glxdricommon.h | 0 glx/{ => glx_dri}/glxdriswrast.c | 0 glx/glxext.c | 7 ++++++- glx/meson.build | 17 ++++++++++------- include/meson.build | 7 ++++--- meson.build | 14 ++++++++++++++ meson_options.txt | 3 +++ 9 files changed, 37 insertions(+), 11 deletions(-) rename glx/{ => glx_dri}/glxdri2.c (100%) rename glx/{ => glx_dri}/glxdricommon.c (100%) rename glx/{ => glx_dri}/glxdricommon.h (100%) rename glx/{ => glx_dri}/glxdriswrast.c (100%) diff --git a/glx/glxdri2.c b/glx/glx_dri/glxdri2.c similarity index 100% rename from glx/glxdri2.c rename to glx/glx_dri/glxdri2.c diff --git a/glx/glxdricommon.c b/glx/glx_dri/glxdricommon.c similarity index 100% rename from glx/glxdricommon.c rename to glx/glx_dri/glxdricommon.c diff --git a/glx/glxdricommon.h b/glx/glx_dri/glxdricommon.h similarity index 100% rename from glx/glxdricommon.h rename to glx/glx_dri/glxdricommon.h diff --git a/glx/glxdriswrast.c b/glx/glx_dri/glxdriswrast.c similarity index 100% rename from glx/glxdriswrast.c rename to glx/glx_dri/glxdriswrast.c diff --git a/glx/glxext.c b/glx/glxext.c index 28b72e33c4..cab58f8f73 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -272,7 +272,12 @@ glxClientCallback(CallbackListPtr *list, void *closure, void *data) /************************************************************************/ -static __GLXprovider *__glXProviderStack = &__glXDRISWRastProvider; +static __GLXprovider *__glXProviderStack = +#ifdef BUILD_GLX_DRI + &__glXDRISWRastProvider; +#else + NULL; +#endif void GlxPushProvider(__GLXprovider * provider) diff --git a/glx/meson.build b/glx/meson.build index 3a14bd27c3..a35ddc8112 100644 --- a/glx/meson.build +++ b/glx/meson.build @@ -13,8 +13,6 @@ srcs_glx = [ 'glxcmds.c', 'glxcmdsswap.c', 'glxext.c', - 'glxdriswrast.c', - 'glxdricommon.c', 'glxscreens.c', 'render2.c', 'render2swap.c', @@ -30,6 +28,16 @@ srcs_glx = [ 'xfont.c', ] +srcs_glxdri2 = [] +if build_glx_dri + srcs_glx += 'glx_dri/glxdriswrast.c' + srcs_glx += 'glx_dri/glxdricommon.c' + + if build_dri2 or build_dri3 + srcs_glxdri2 = files('glx_dri/glxdri2.c') + endif +endif + libxserver_glx = [] if build_glx libxserver_glx = static_library('xserver_glx', @@ -50,11 +58,6 @@ if build_glx ) endif -srcs_glxdri2 = [] -if build_dri2 or build_dri3 - srcs_glxdri2 = files('glxdri2.c') -endif - srcs_vnd = [ 'vndcmds.c', 'vndext.c', diff --git a/include/meson.build b/include/meson.build index 36af68b85c..6f1bb5fcc1 100644 --- a/include/meson.build +++ b/include/meson.build @@ -6,8 +6,6 @@ patch = version_split[2].to_int() # convert to the old-style 1.x.y version scheme used up to 1.20.x for backwards compatibility release = 1 * 10000000 + major * 100000 + minor * 1000 + patch -dri_dep = dependency('dri', required: build_glx) - # For feature macros we're using either false (boolean) or '1', which correspond to the macro being # not defined at all and defined to 1. This is to match autotools behavior and thus preserve # backwards compatibility with all the existing code that uses #ifdef to check if feature is @@ -222,7 +220,10 @@ conf_data.set('DPMSExtension', build_dpms ? '1' : false) conf_data.set('DRI2', build_dri2 ? '1' : false) conf_data.set('DRI3', build_dri3 ? '1' : false) if build_glx - conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_variable(pkgconfig : 'dridriverdir')) + if build_glx_dri + conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_variable(pkgconfig : 'dridriverdir')) + conf_data.set('BUILD_GLX_DRI', 1) + endif endif conf_data.set('MITSHM', build_mitshm ? '1' : false) conf_data.set('CONFIG_MITSHM', build_mitshm ? '1' : false) diff --git a/meson.build b/meson.build index 30eb8fb2d9..55a3193295 100644 --- a/meson.build +++ b/meson.build @@ -475,6 +475,20 @@ if build_glx build_hashtable = true endif +dri_dep = dependency('dri', required: false) + +glx_dri_opt = get_option('glx_dri') +build_glx_dri = (glx_dri_opt != 'false') +if not dri_dep.found() + if glx_dri_opt == 'auto' + build_glx_dri = false + endif + + if glx_dri_opt == 'true' + error('DRI glx backends requested, but dri.pc was not found') + endif +endif + libdrm_dep = dependency('libdrm', version: libdrm_req, required: false) if get_option('dri1') == 'auto' diff --git a/meson_options.txt b/meson_options.txt index 99e65e7139..712b3ebbf0 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -37,6 +37,9 @@ option('fontrootdir', type: 'string', option('serverconfigdir', type: 'string', description: 'Miscellaneous server configuration files path. Default: $libdir/xorg') +option('glx_dri', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Build the dri-based glx backends. Default: true') + option('glx', type: 'boolean', value: true) option('xdmcp', type: 'boolean', value: true) option('xdm-auth-1', type: 'boolean', value: true)