public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Dimitar Dimitrov <dimitar@dinux.eu>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	Jonathan Wakely <jwakely@redhat.com>
Subject: Re: [PATCH] libstdc++: Decouple HAVE_FCNTL_H from HAVE_DIRENT_H check
Date: Tue, 8 Feb 2022 21:18:45 +0000	[thread overview]
Message-ID: <CAH6eHdTCtxQ6NVh9gEVcne+CXWqzu9DffdEhK1spqHQWmgLJ+A@mail.gmail.com> (raw)
In-Reply-To: <YgLaW2g29YnlPbjO@kendros>

On Tue, 8 Feb 2022 at 21:02, Dimitar Dimitrov <dimitar@dinux.eu> wrote:

> On Mon, Feb 07, 2022 at 09:05:45PM +0000, Jonathan Wakely wrote:
> > On Mon, 7 Feb 2022 at 21:01, Jonathan Wakely <jwakely.gcc@gmail.com>
> wrote:
> >
> > >
> > >
> > > On Mon, 7 Feb 2022 at 20:12, Dimitar Dimitrov <dimitar@dinux.eu>
> wrote:
> > >
> > >> On PRU target with newlib, we have the following combination in
> config.h:
> > >>   /* #undef HAVE_DIRENT_H */
> > >>   #define HAVE_FCNTL_H 1
> > >>   #define HAVE_UNLINKAT 1
> > >>
> > >> In newlib, targets which do not define dirent.h, get a build error
> when
> > >> including <dirent.h>:
> > >>
> > >>
> https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/dirent.h;hb=HEAD
> > >>
> > >> While fs_dir.cc correctly checks for HAVE_FCNTL_H, dir-common.h
> doesn't,
> > >> and instead uses HAVE_DIRENT_H. This results in unlinkat() function
> call
> > >> in fs_dir.cc without the needed <fcntl.h> include in dir-common.h.
> Thus
> > >> a build failure:
> > >>   .../gcc/libstdc++-v3/src/c++17/fs_dir.cc:151:11: error: ‘::unlinkat’
> > >> has not been declared; did you mean ‘unlink’?
> > >>
> > >> Fix by encapsulating <fcntl.h> include with the correct check.
> > >>
> > >
> > > But there's no point doing anything in that file if we don't have
> > > <dirent.h>, the whole thing is unusable. There's no point making the
> > > members using unlinkat compile if you can't ever construct the type.
> > >
> > > So I think we want a different fix.
> > >
> >
> >
> > Maybe something like:
> >
> > --- a/libstdc++-v3/src/filesystem/dir-common.h
> > +++ b/libstdc++-v3/src/filesystem/dir-common.h
> > @@ -70,6 +70,8 @@ struct DIR { };
> > inline DIR* opendir(const char*) { return nullptr; }
> > inline dirent* readdir(DIR*) { return nullptr; }
> > inline int closedir(DIR*) { return -1; }
> > +#undef _GLIBCXX_HAVE_DIRFD
> > +#undef _GLIBCXX_HAVE_UNLINKAT
> > #endif
> > } // namespace __gnu_posix
> Yes, this fixes the PRU target, and does not regress
> x86_64-pc-linux-gnu.
>

Thanks for checking it. I'm just testing it myself on powerpc64le-linux-gnu
and will push when it finishes.

  reply	other threads:[~2022-02-08 21:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 20:10 Dimitar Dimitrov
2022-02-07 21:01 ` Jonathan Wakely
2022-02-07 21:05   ` Jonathan Wakely
2022-02-08 21:02     ` Dimitar Dimitrov
2022-02-08 21:18       ` Jonathan Wakely [this message]
2022-02-10 13:03         ` [committed] " Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdTCtxQ6NVh9gEVcne+CXWqzu9DffdEhK1spqHQWmgLJ+A@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=dimitar@dinux.eu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).