Merge branch 'tls-config-options' into 'master'

Add test coverage for TLS/TSD combinations

See merge request glvnd/libglvnd!251
This commit is contained in:
Kyle Brenneman 2021-10-27 18:29:35 +00:00
commit f73ae47989
3 changed files with 38 additions and 8 deletions

View File

@ -84,7 +84,13 @@ build-x86_64-tsd-meson:
extends:
- .build-check-meson
variables:
CONFIGURE_OPTIONS: -Dtls=disabled
CONFIGURE_OPTIONS: -Dtls=false
build-x86_64-tsd-tls-meson:
extends:
- .build-check-meson
variables:
CONFIGURE_OPTIONS: -Ddispatch-tls=false
build-i386-tsd:
extends:
@ -96,7 +102,13 @@ build-i386-tsd-meson:
extends:
- .build-check-meson
variables:
CONFIGURE_OPTIONS: -Dtls=disabled --cross-file .gitlab-ci/i686-linux-gnu
CONFIGURE_OPTIONS: -Dtls=false --cross-file .gitlab-ci/i686-linux-gnu
build-i386-tsd-tls-meson:
extends:
- .build-check-meson
variables:
CONFIGURE_OPTIONS: -Ddispatch-tls=false --cross-file .gitlab-ci/i686-linux-gnu
build-pure-c-tls:
extends:
@ -120,4 +132,4 @@ build-pure-c-tld-meson:
extends:
- .build-check-meson
variables:
CONFIGURE_OPTIONS: -Dasm=disabled -Dtls=disabled
CONFIGURE_OPTIONS: -Dasm=disabled -Dtls=false

View File

@ -110,14 +110,17 @@ if cc.compiles('typeof(int *);', name : 'typeof')
endif
with_tls = get_option('tls')
if with_tls.auto()
if with_tls
# Use a __thread variable if possible, even if we can't use the TLS assembly
# stubs, because it's still faster than calling pthread_getspecific.
have_tls = cc.compiles(
'__thread int foo;',
name : '__thread',
)
else
have_tls = with_tls.enabled()
have_tls = false
endif
message('Using TLS variable for dispatch table: @0@'.format(have_tls))
if have_tls
add_project_arguments('-DGLDISPATCH_USE_TLS', language : ['c'])
@ -129,7 +132,15 @@ if use_asm
# FreeBSD and glibc). on other platforms we use TSD stubs to allow calling
# extension functions unknown at compile time.
# https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/249
thread_type = have_tls and (host_machine.system() == 'freebsd' or cc.has_header_symbol('features.h', '__GLIBC__')) ? 'tls' : 'tsd'
thread_type = 'tsd'
if get_option('dispatch-tls')
if have_tls
if host_machine.system() == 'freebsd' or cc.has_header_symbol('features.h', '__GLIBC__')
thread_type = 'tls'
endif
endif
endif
if host_machine.cpu_family().startswith('x86')
gl_dispatch_type = '@0@_@1@'.format(
host_machine.cpu_family(),

View File

@ -56,8 +56,15 @@ option(
)
option(
'tls',
type : 'feature',
description : 'Use Thread Local Storage.'
type : 'boolean',
value : true,
description : 'Use Thread Local Storage (if supported).'
)
option(
'dispatch-tls',
type : 'boolean',
value : true,
description : 'Use TLS-based stubs in libGLdispatch (if supported).'
)
option(
'dispatch-page-size',