From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id E59D23858D28; Tue, 8 Feb 2022 21:18:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E59D23858D28 Received: by mail-wm1-x330.google.com with SMTP id bg21-20020a05600c3c9500b0035283e7a012so216816wmb.0; Tue, 08 Feb 2022 13:18:57 -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=wlFBph1dJM5QgAYf+QoHVwYPzU4CjLqaSRJDGNrXBCo=; b=uoKcA5cb/9utqCaaRfb66sVfs+aCQzJKAJfNBU1onmYtvjJcyaVMmAyRO3FQzkw7F4 rd8tacBA73UFFFFTWDQ8qKNAysq8CJBD2zp4sDOXZOX5KL4ZhUe2MnsvlAgEmjvmMivq BFM7TSRhlP+xRb/MOMdomHNHSYKzhgjyUgnev7QAFoyWqEaqLRrZ7TMdRIDeSVTuvGPo xhoSJwFZMMvnpqChSS7iYDfOIW5SxLgydNBGCGh/Gg3JtnY+gTEkJ9GvS4LYT2oZwjR+ 1+z7uIisD3qh/klSzuwqx7RmD06eW6dSJn7QR7QKBqWhwjC82o7xWYZUu9vKE8czl7+V IPmg== X-Gm-Message-State: AOAM532bb5iKkeKm7kPgAQ043fT359EbQEORggq5yJGTaI8jhdMd7ZGJ 422svhl4PuOvVt3jJmdU80akP146XT6J3yArZHs= X-Google-Smtp-Source: ABdhPJyEKe2B9vNkgHpcKAaXfFZwY2lqn8lcj0gVPxAvAzgvjBWXoKL8KSsnfp462lfgo7bICEG17Fzx4BqkDva+m/w= X-Received: by 2002:a05:600c:4ca1:: with SMTP id g33mr2659751wmp.108.1644355136906; Tue, 08 Feb 2022 13:18:56 -0800 (PST) MIME-Version: 1.0 References: <20220207201058.250114-1-dimitar@dinux.eu> In-Reply-To: From: Jonathan Wakely Date: Tue, 8 Feb 2022 21:18:45 +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=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: Tue, 08 Feb 2022 21:19:00 -0000 On Tue, 8 Feb 2022 at 21:02, Dimitar Dimitrov wrote: > On Mon, Feb 07, 2022 at 09:05:45PM +0000, Jonathan Wakely wrote: > > On Mon, 7 Feb 2022 at 21:01, Jonathan Wakely > wrote: > > > > > > > > > > > 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:= :unlinkat=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. > > > > > > > > > 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.