Richard Biener <richard.guent...@gmail.com> writes:

> On Thu, Aug 28, 2025 at 7:23 AM Sam James <s...@gentoo.org> wrote:
>>
>> GNU2 TLS descriptors were introduced in 2006 (r0-73091-g5bf5a10b1ccacf)
>> but were only opt-in with -mtls-dialect=gnu2. They are more efficient
>> and it's time to enable them by default.
>>
>> Builds on the --with-tls= machinery from r16-3355-g96a291c4bb0b8a.
>>
>> We achieve this for GNU/Linux IA-32/X86-64 targets by checking if ld emits
>> GLIBC_ABI_GNU2_TLS, using its presence to decide if we can default to
>> -mtls-dialect=gnu2.
>>
>> For PR ld/33130, newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured
>> (auto mode) or if configured with --enable-gnu2-tls-tag. In auto mode,
>> GLIBC_ABI_GNU2_TLS is only added if glibc provides it. In explicit mode, the
>> user has asked for this behavior and binaries will depend on 
>> GLIBC_ABI_GNU2_TLS
>> and fixed glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can
>> safely default to GNU2 TLS descriptors. We added GLIBC_ABI_GNU2_TLS in glibc
>> to indicate that PR dynamic-link/33129 is fixed.
>>
>> If distributions wish to opt-out of this for systems which meet the above
>> conditions, they can either configure GCC using --with-tls=gnu, or configure
>> binutils with --disable-gnu2-tls-tag: if this is necessary, it is recommended
>> to use --with-tls=gnu instead, to avoid affecting the ecosystem negatively by
>> having unmarked binaries.
>
> I wonder if we can piggy-back on the existing --with-glibc-version=... 
> somehow?

Yeah, that sounds OK. I can have a look, if you're okay in principle
with doing it "optimistically" (i.e. not the only condition for
defaulting), so:

* --with-glibc-version=new-enough => default to gnu2
* unpassed --with-glibc-version   => use the test from this patch ("optimistic")
* --with-glibc-version=too-old    => don't default to gnu2

> [...]

sam

Reply via email to