summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build28
1 files changed, 19 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('''