mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 16:00:08 +01:00
meson: Additionally probe -mtls-dialect=desc for TLSDESC support
Previously only `-mtls-dialect=gnu2` was probed, which was appropriate for arm, x86 and x86_64, but not for newer architectures such as aarch64, loongarch64 and riscv64 which all use `-mtls-dialect=desc` instead. Because the driver option is not consistent across architectures (and probably will not), try both variants and choose the first one working. While at it, rename "gnu2_*" variables to "tlsdesc_*" respectively, for clarity. Cc: mesa-stable Reviewed-by: Icenowy Zheng <uwu@icenowy.me> Reviewed-by: Yukari Chiba <i@0x7f.cc> Reviewed-by: David Heidelberg <david@ixit.cz> Signed-off-by: WANG Xuerui <git@xen0n.name> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30599>
This commit is contained in:
parent
56f38672a2
commit
cc2dbb8ea5
1 changed files with 22 additions and 16 deletions
38
meson.build
38
meson.build
|
|
@ -502,22 +502,28 @@ if not have_mtls_dialect
|
||||||
if meson.is_cross_build() and not meson.can_run_host_binaries()
|
if meson.is_cross_build() and not meson.can_run_host_binaries()
|
||||||
warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
|
warning('cannot auto-detect -mtls-dialect when cross-compiling, using compiler default')
|
||||||
else
|
else
|
||||||
# -fpic to force dynamic tls, otherwise TLS relaxation defeats check
|
# The way to specify the TLSDESC dialect is architecture-specific.
|
||||||
gnu2_test = cc.run('int __thread x; int main() { return x; }',
|
# We probe both because there is not a fallback guaranteed to work for all
|
||||||
args: ['-mtls-dialect=gnu2', '-fpic'],
|
# future architectures.
|
||||||
name: '-mtls-dialect=gnu2')
|
foreach tlsdesc_arg : ['-mtls-dialect=gnu2', '-mtls-dialect=desc']
|
||||||
if gnu2_test.returncode() == 0 and (
|
# -fpic to force dynamic tls, otherwise TLS relaxation defeats check
|
||||||
# check for lld 13 bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
|
tlsdesc_test = cc.run('int __thread x; int main() { return x; }',
|
||||||
host_machine.cpu_family() != 'x86_64' or
|
args: [tlsdesc_arg, '-fpic'],
|
||||||
# get_linker_id misses LDFLAGS=-fuse-ld=lld: https://github.com/mesonbuild/meson/issues/6377
|
name: tlsdesc_arg)
|
||||||
#cc.get_linker_id() != 'ld.lld' or
|
if tlsdesc_test.returncode() == 0 and (
|
||||||
cc.links('''int __thread x; int y; int main() { __asm__(
|
# check for lld 13 bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
|
||||||
"leaq x@TLSDESC(%rip), %rax\n"
|
host_machine.cpu_family() != 'x86_64' or
|
||||||
"movq y@GOTPCREL(%rip), %rdx\n"
|
# get_linker_id misses LDFLAGS=-fuse-ld=lld: https://github.com/mesonbuild/meson/issues/6377
|
||||||
"call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
|
#cc.get_linker_id() != 'ld.lld' or
|
||||||
)
|
cc.links('''int __thread x; int y; int main() { __asm__(
|
||||||
c_cpp_args += '-mtls-dialect=gnu2'
|
"leaq x@TLSDESC(%rip), %rax\n"
|
||||||
endif
|
"movq y@GOTPCREL(%rip), %rdx\n"
|
||||||
|
"call *x@TLSCALL(%rax)\n"); }''', name: 'split TLSDESC')
|
||||||
|
)
|
||||||
|
c_cpp_args += tlsdesc_arg
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue