diff --git a/meson.build b/meson.build index 6b041dac8f8..620ae7adc11 100644 --- a/meson.build +++ b/meson.build @@ -1805,10 +1805,17 @@ endif dep_selinux = null_dep if get_option('selinux') + if get_option('execmem') != true + warning('execmem option is disabled, selinux will not be able to use execmem.') + endif dep_selinux = dependency('libselinux') pre_args += '-DMESA_SELINUX' endif +if get_option('execmem') + pre_args += '-DMESA_EXECMEM' +endif + _libunwind = get_option('libunwind') if _libunwind == 'true' _libunwind = 'enabled' diff --git a/meson_options.txt b/meson_options.txt index 11feb3f6763..84150789f3c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -377,7 +377,13 @@ option( 'selinux', type : 'boolean', value : false, - description : 'Build an SELinux-aware Mesa' + description : 'Build an SELinux-aware Mesa. This currently disables execmem support at runtime unless SELinux is configured with allow_execmem.' +) +option( + 'execmem', + type : 'boolean', + value : true, + description : 'Enable execmem support. Without execmem, glapi will fail to generate dynamic glapi stubs when entrypoints unknown to glapi but known to DRI drivers are requested in eglGetProcAddress or glXGetProcAddress. This should be enabled unless the platform can guarantee glapi and DRI drivers are always built from the same source tree.' ) option( 'osmesa', diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c index d6e64c08886..2bb63d02b26 100644 --- a/src/mapi/u_execmem.c +++ b/src/mapi/u_execmem.c @@ -121,6 +121,10 @@ init_map(void) void * u_execmem_alloc(unsigned int size) { +#ifndef MESA_EXECMEM + (void)size; + return NULL; +#else void *addr = NULL; mtx_lock(&exec_mutex); @@ -140,6 +144,7 @@ bail: mtx_unlock(&exec_mutex); return addr; +#endif /* MESA_EXECMEM */ }