[PATCH v2 19/28] x86: Fix THREAD_GSCOPE_RESET_FLAG build on clang

Uros Bizjak ubizjak@gmail.com
Wed Oct 29 07:13:53 GMT 2025



On 10/28/25 18:08, Adhemerval Zanella wrote:
> clang does not support __seg_fs in asm constraint.
> ---
>   sysdeps/x86_64/nptl/tls.h | 22 ++++++++++++++++++----
>   1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
> index abfeb88054..809d90875a 100644
> --- a/sysdeps/x86_64/nptl/tls.h
> +++ b/sysdeps/x86_64/nptl/tls.h
> @@ -198,13 +198,27 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
>   # define THREAD_GSCOPE_FLAG_UNUSED 0
>   # define THREAD_GSCOPE_FLAG_USED   1
>   # define THREAD_GSCOPE_FLAG_WAIT   2
> +
> +/* clang does not support __seg_fs in asm constraint.  */
> +# ifdef __clang__
> +#  define XCHGL_GSCOPE(__r)						      \
> +   asm volatile ("xchgl %%fs:%c1, %0"					      \
> +                 : "=r" (__r)						      \
> +                 : "i" (offsetof (struct pthread, header.gscope_flag)),	      \
> +		   "0" (THREAD_GSCOPE_FLAG_UNUSED)			      \
> +		 : "memory")

Does:

    asm volatile ("xchgl %%fs:%1, %0"				\
		 : "=r" (__r)				\
		 : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag),  \
		   "0" (THREAD_GSCOPE_FLAG_UNUSED))

work with clang?

Uros.


More information about the Libc-alpha mailing list