From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id A9F053858C83; Mon, 7 Feb 2022 21:01:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A9F053858C83 Received: by mail-wm1-x329.google.com with SMTP id o1-20020a1c4d01000000b0034d95625e1fso147470wmh.4; Mon, 07 Feb 2022 13:01:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8Y7AVGF0UkdjiL8QoAht0tXxkai7s0D2e0BEFkGpEPs=; b=z9Ssq+4a9sYMsd6Aqy3X+Zk9v2X1El68uWh8hEHdkRhomRxeObBZxMkqYMP/XlUnMw wvf6zveIl5OBG92qKWtjd16iITtkzbewDnUwcOTyCBX89v1H86LA1/Nm2Xi8JC50NiUf GWtRjlojHUgFVjs76Y6N94wmX7HXvWKfLqZyhIIkjpldgzzmOhmyNSt62m1ca6EKJNSz DZGF/UBygi0ljZZSu/xrfqLlNrkfwrPSINxdexb/ABqiYT+tK6mE+Frw+HEzdVG24wQG oWEw14ZtC0ofaEBOA3KzNWqYtjdEciUieHIF5bFkNdjvtF2jsyKjmKE0PMlUPAslrpu8 1oxA== X-Gm-Message-State: AOAM533gMjmj2ggzIDEJJdNqRVVLbgcHbh/PCoOZknks2roAtzkbpEde rHCXjet4PQz8u3/+auJ4V/4upPjwnpg3DuRbBv8= X-Google-Smtp-Source: ABdhPJyEpaSJhmNSmYYApccuV2mL7/rcET5usY+cV3HNDcjICE3HLZw+t4xE9ZebYl7wLMIPYXYX5ZCvanp0qEVn+3o= X-Received: by 2002:a05:600c:1151:: with SMTP id z17mr550741wmz.169.1644267702572; Mon, 07 Feb 2022 13:01:42 -0800 (PST) MIME-Version: 1.0 References: <20220207201058.250114-1-dimitar@dinux.eu> In-Reply-To: <20220207201058.250114-1-dimitar@dinux.eu> From: Jonathan Wakely Date: Mon, 7 Feb 2022 21:01:30 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Decouple HAVE_FCNTL_H from HAVE_DIRENT_H check To: Dimitar Dimitrov Cc: "libstdc++" , gcc-patches , Jonathan Wakely X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Feb 2022 21:01:45 -0000 On Mon, 7 Feb 2022 at 20:12, Dimitar Dimitrov 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 : > > https://sourceware.org/git/?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dnewlib/lib= c/include/sys/dirent.h;hb=3DHEAD > > 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 include in dir-common.h. Thus > a build failure: > .../gcc/libstdc++-v3/src/c++17/fs_dir.cc:151:11: error: =E2=80=98::unli= nkat=E2=80=99 has > not been declared; did you mean =E2=80=98unlink=E2=80=99? > > Fix by encapsulating include with the correct check. > But there's no point doing anything in that file if we don't have , 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. > Regtested x86_64-pc-linux-gnu and no new failures detected. > > Fixes commit r12-7062-gebf61754647689 (libstdc++: Fix > filesystem::remove_all races). > > libstdc++-v3/ChangeLog: > > * src/filesystem/dir-common.h (_GLIBCXX_HAVE_FCNTL_H): Move the > check outside the HAVE_DIRENT_H check. > > Signed-off-by: Dimitar Dimitrov > --- > libstdc++-v3/src/filesystem/dir-common.h | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/libstdc++-v3/src/filesystem/dir-common.h > b/libstdc++-v3/src/filesystem/dir-common.h > index 0b7665a3f70..cfce4fae9a4 100644 > --- a/libstdc++-v3/src/filesystem/dir-common.h > +++ b/libstdc++-v3/src/filesystem/dir-common.h > @@ -35,10 +35,11 @@ > # include > # endif > # include // opendir, readdir, fdopendir, dirfd > -# ifdef _GLIBCXX_HAVE_FCNTL_H > -# include // open, openat, fcntl, AT_FDCWD, O_NOFOLLOW etc. > -# include // close, unlinkat > -# endif > +#endif > + > +#ifdef _GLIBCXX_HAVE_FCNTL_H > +# include // open, openat, fcntl, AT_FDCWD, O_NOFOLLOW etc. > +# include // close, unlinkat > #endif > > namespace std _GLIBCXX_VISIBILITY(default) > -- > 2.34.1 > >