summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Gilbert <bgilbert@backtick.net>2022-06-29 01:28:23 -0400
committerMatt Turner <mattst88@gmail.com>2022-10-18 01:02:43 +0000
commit421fc252ab7e8768f1d200f064f5222c5c9b7b63 (patch)
treee0a4f2da2dedb45922805a8bea6b11d7f9f92a8a
parent7989483929aa1b4b5db6bc0bca8137b640b6dda2 (diff)
meson: Add feature to disable compiler TLS support
When compiling with MinGW, use of the __thread attribute causes pixman to gain a dependency on the winpthread DLL. With Autotools, this could be avoided by configuring with ac_cv_tls=none, causing pixman to fall back to TlsSetValue() instead. Add a Meson 'tls' option that can be 'disabled' to skip support for TLS compiler attributes, or 'enabled' to require a working TLS attribute.
-rw-r--r--meson.build28
-rw-r--r--meson_options.txt5
2 files changed, 24 insertions, 9 deletions
diff --git a/meson.build b/meson.build
index 58a1406..a485d8b 100644
--- a/meson.build
+++ b/meson.build
@@ -492,15 +492,25 @@ foreach h : ['sys/mman.h', 'fenv.h', 'unistd.h']
endif
endforeach
-# gcc on Windows only warns that __declspec(thread) isn't supported,
-# passing -Werror=attributes makes it fail.
-if (host_machine.system() == 'windows' and
- cc.compiles('int __declspec(thread) foo;',
- args : cc.get_supported_arguments(['-Werror=attributes']),
- name : 'TLS via __declspec(thread)'))
- config.set('TLS', '__declspec(thread)')
-elif cc.compiles('int __thread foo;', name : 'TLS via __thread')
- config.set('TLS', '__thread')
+use_tls = get_option('tls')
+have_tls = ''
+if not use_tls.disabled()
+ # gcc on Windows only warns that __declspec(thread) isn't supported,
+ # passing -Werror=attributes makes it fail.
+ if (host_machine.system() == 'windows' and
+ cc.compiles('int __declspec(thread) foo;',
+ args : cc.get_supported_arguments(['-Werror=attributes']),
+ name : 'TLS via __declspec(thread)'))
+ have_tls = '__declspec(thread)'
+ elif cc.compiles('int __thread foo;', name : 'TLS via __thread')
+ have_tls = '__thread'
+ endif
+endif
+
+if have_tls != ''
+ config.set('TLS', have_tls)
+elif use_tls.enabled()
+ error('Compiler TLS Support unavailable, but required')
endif
if cc.links('''
diff --git a/meson_options.txt b/meson_options.txt
index 8a1cfea..99dbb4e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -80,6 +80,11 @@ option(
description : 'Use GNU style inline assembler',
)
option(
+ 'tls',
+ type : 'feature',
+ description : 'Use compiler support for thread-local storage',
+)
+option(
'cpu-features-path',
type : 'string',
description : 'Path to platform-specific cpu-features.[ch] for systems that do not provide it (e.g. Android)',