[PATCH] libstdc++: Use realpath for /etc/localtime symlink [PR125467]

Torbjorn SVENSSON torbjorn.svensson@foss.st.com
Wed Aug 12 13:25:56 GMT 2026



On 2026-08-11 14:12, Andreas Schwab wrote:
> On Aug 11 2026, Torbjorn SVENSSON wrote:
> 
>> In _swistat, the following statements are of interrest:
>>
>>    /* Always assume a character device,
>>       with 1024 byte blocks. */
>>    st->st_mode |= S_IFCHR;
>>    st->st_blksize = 1024;
>>
>> This, together with
>>
>>    st->st_mode |= S_IFREG | S_IREAD;
>>
>> from _stat will set the bits in a way that makes libstdc++ think that the
>> checked path is a symlink, even if the checked path actually a regular
>> directory.
> 
> That looks like a bug that needs to be fixed in newlib.
> 

I'm not arguing that there is no bug in newlib around this, but how
is the tzdb support supposed to work when you link with --specs=nosys.specs,
i.e., you have disable syscalls?

I think it makes sense to fall back to the built in database in case the
filesystem can not the accessed. At least for bare metal, this sounds more
appealing that having to implement _stat() etc and fake success in order
to be able to use default tz info.

Am I completely off track on this?

FYI, I am working on trying to patch newlib in a way that semihosting would
properly detect directories.

Kind regards,
Torbjörn



More information about the Libstdc++ mailing list