[RSB 1/3] 6/7: Update Newlib

Chris Johns chrisj at rtems.org
Thu Jul 21 06:10:48 UTC 2022

On 21/7/2022 3:21 pm, Sebastian Huber wrote:
> On 20.07.22 22:52, Chris Johns wrote:
>> On 20/7/2022 6:20 pm, Sebastian Huber wrote:
>>> On 20/07/2022 10:11, Chris Johns wrote:
>>>>>> Are these TLS allocations in newlib based on a single use of a newlib call
>>>>>> that
>>>>>> brings in the reent stuff? How does that work?
>>>>> No, each TLS object is defined in the translation unit which uses the object.
>>>>> The goal is to get only those objects linked in which are needed.
>>>>> Currently, the
>>>>> Newlib thread delete hook pulls in some objects, however, this dependency will
>>>>> go away once the TLS destructors are implemented.
>>>> If I have task A and it opens a file and writes something to a file system will
>>>> it pull in the TLS support for files?
>>> Yes.
>>>> Given the TLS support is static does this mean all threads in the A app
>>>> allocate
>>>> the newlib file TLS variables even if they never use newlib?
>>> Yes.
>>>> My understanding of the existing reent support is tasks that do not use newlib
>>>> it never allocate a reent struct?
>>> No, the struct _reent is allocated for all tasks if you don't use
>>> CONFIGURE_DISABLE_NEWLIB_REENTRANCY (which is not recommended). How would you
>>> know if a task doesn't use Newlib?
>> I thought the get would do a check and then allocate on first use. It has been
>> many years since I looked at the implementation.
>> I think this change is a good one because it will reduce the needed memory to
>> the amount used and it will have better performance.
>> I think option you post is a good thing to add, maybe as
>> --enable-newlib-reent-tls. What will be the default?
> You mean a proper sb-set-builder option and not just a --with-newlib-tls?

Not an sb option rather something using the --wtih/--without flags. I just
renamed yours as `thread-local` may not be as well know as TLS.

> I
> would make it the default for the targets with known to work TLS support:
> aarch64, arm, nios2, powerpc, riscv, and sparc.

Sure it can be the default for the archs that can support it but a
--without-newlib-tls option might be useful to someone using libdl if this
change breaks their usage, ie linking from archives on the target.


More information about the devel mailing list