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

Jonathan Wakely <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.libstdc++.devel
Message-ID <CACb0b4k2KLPH-U-Um7CQMG4BJ2D9okj2eLAJjwu9f0N5zh9Bcg@mail.gmail.com>
On Wed, 12 Aug 2026 at 14:26, Torbjorn SVENSSON
<[email protected]> wrote:
>
>
>
> 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?

Arguably, if you ask for the system's current time zone as defined by
/etc/localtime and there is no /etc/localtime, it's OK to get an
exception.
If you want to default to UTC instead of checking a non-existent
filesystem, you can just use chrono::locate_zone("UTC") instead of
using chrono::current_zone().

But I think it is more useful to treat "cannot access the filesystem"
the same way as "we do not know how to determine the system time zone
on this OS" and so that means defaulting to UTC.

So I agree with your change to avoid the exception.

>
> FYI, I am working on trying to patch newlib in a way that semihosting would
> properly detect directories.
>
> Kind regards,
> Torbjörn
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.