Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 24 Jun 2022 22:51:57 -0700
From: Fangrui Song <i@...kray.me>
To: musl@...ts.openwall.com
Cc: mesa-dev@...ts.freedesktop.org
Subject: Re: Fwd: mesa | Remove USE_ELF_TLS macro (!17213)

On 2022-06-25, 罗勇刚(Yonggang Luo) wrote:
>On Sat, Jun 25, 2022 at 12:47 PM Markus Wichmann <nullplan@....net> wrote:
>>
>> On Sat, Jun 25, 2022 at 11:36:09AM +0800, 罗勇刚(Yonggang Luo) wrote:
>> > So I am confused. What's the situation about ELF-TLS support in musl?
>> > Is that still broken now?
>>
>> musl has always supported ELF-TLS anywhere except in libc itself. That
>> was also never the problem. The problem was that the mesa people select
>> the initial-exec TLS model explicitly, even though libGL ends up being
>> dlopen()ed quite often, and then you should be using the general-dynamic
>> model instead.
>
>My question is does musl support ELS-TLS when using dl-open.

It is supported.

For shared objects using the initial-exec TLS model, they must be at load time (DT_NEEDED),
not via dlopen.
See https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
for background.

>
>>
>> According to [1], Rich proposed dropping the initial-exec attribute and
>> replacing it with -mtls-dialect=gnu2 eight years ago. Has that happened
>> yet? If so, dlopen()ing libGL with musl ought to work.
>
>`initial-exec` are only specified for  __GLIBC__, If musl  not predefined
>macro ` __GLIBC__`
>```
>#if defined(__GLIBC__)
>#define __THREAD_INITIAL_EXEC thread_local
>__attribute__((tls_model("initial-exec")))
>#define REALLY_INITIAL_EXEC
>#else
>#define __THREAD_INITIAL_EXEC thread_local
>#endif
>```

On x86, you may enable (currently GCC only) -mtls-dialect=gnu2 to get
performance boost. It's just a tiny bit slower than initial-exec.

I added x86-32 TLSDESC and mixed TLS GD/TLSDESC support to lld 14 after
I saw the -mtls-dialect=gnu2 build system improvement in mesa :)

>
>>
>> Ciao,
>> Markus
>>
>> [1] https://gitlab.freedesktop.org/mesa/mesa/-/issues/966
>
>
>
>--
>         此致
>礼
>罗勇刚
>Yours
>    sincerely,
>Yonggang Luo

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.