From patchwork Thu Jan 24 18:47:58 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: meson: add toggle for TLS support in GLX
From: Patrick Steinhardt <ps@pks.im>
X-Patchwork-Id: 280319
Message-Id: <225b2b2d4a43c43f035a55dd8e9c2217482f8fee.1548355622.git.ps@pks.im>
To: mesa-dev@lists.freedesktop.org
Cc: Patrick Steinhardt <ps@pks.im>
Date: Thu, 24 Jan 2019 19:47:58 +0100

The musl libc library does not have any support for the
"initial-exec" TLS model and is unlikely to ever implement it.
Thus, TLS support in GLX has been turned off in musl-based
distributions to work around problems when dlopen'ing drivers.
While this is easily possible using the autoconf build system by
passing `--disable-glx-tls`, meson does not yet have such an
option.

Add a new toggle "glx-tls" that defaults to `true` to gain parity
with autoconf. If disabled, `GLX_USE_TLS` will not be defined and
thus mesa will be built without TLS support.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build       | 6 +++++-
 meson_options.txt | 6 ++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 34e2a03254..3981bf1a67 100644
--- a/meson.build
+++ b/meson.build
@@ -50,6 +50,7 @@ with_tests = get_option('build-tests')
 with_valgrind = get_option('valgrind')
 with_libunwind = get_option('libunwind')
 with_asm = get_option('asm')
+with_glx_tls = get_option('glx-tls')
 with_glx_read_only_text = get_option('glx-read-only-text')
 with_glx_direct = get_option('glx-direct')
 with_osmesa = get_option('osmesa')
@@ -332,7 +333,10 @@ if with_egl and not (with_platform_drm or with_platform_surfaceless)
   endif
 endif
 
-pre_args += '-DGLX_USE_TLS'
+if with_glx_tls
+  pre_args += '-DGLX_USE_TLS'
+endif
+
 if with_glx != 'disabled'
   if not (with_platform_x11 and with_any_opengl)
     error('Cannot build GLX support without X11 platform support and at least one OpenGL API')
diff --git a/meson_options.txt b/meson_options.txt
index bfb06c4dd4..8ff63f20b4 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -224,6 +224,12 @@ option(
   value : true,
   description : 'Build assembly code if possible'
 )
+option(
+  'glx-tls',
+  type : 'boolean',
+  value : true,
+  description : 'Enable TLS support in GLX'
+)
 option(
    'glx-read-only-text',
    type : 'boolean',
