summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)',