mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 05:10:11 +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>
(cherry picked from commit cc2dbb8ea5)
This commit is contained in:
parent
5a16eefb6a
commit
24d0e7eefe
2 changed files with 23 additions and 17 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "meson: Additionally probe -mtls-dialect=desc for TLSDESC support",
|
"description": "meson: Additionally probe -mtls-dialect=desc for TLSDESC support",
|
||||||
"nominated": true,
|
"nominated": true,
|
||||||
"nomination_type": 0,
|
"nomination_type": 0,
|
||||||
"resolution": 0,
|
"resolution": 1,
|
||||||
"main_sha": null,
|
"main_sha": null,
|
||||||
"because_sha": null,
|
"because_sha": null,
|
||||||
"notes": null
|
"notes": null
|
||||||
|
|
|
||||||
38
meson.build
38
meson.build
|
|
@ -505,22 +505,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