From patchwork Thu Feb 10 13:03:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1591000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=XY6v7MIZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvcQW4G01z9s8s for ; Fri, 11 Feb 2022 00:04:18 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D20573858429 for ; Thu, 10 Feb 2022 13:04:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D20573858429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644498255; bh=DyBIVhTEOS7P+0VdI6OocY/fU6oezDAjZa4NqXwnn5k=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XY6v7MIZNSmMntKzg6Uk/WFYukdvrmYZkKSxGE8vzStFR+GNihcEH/oO1/878or6K PA5h+6ee4mxoCtj/kCHEpNlF4g5gYiudJbQdFrb4+05PEzr/ZmX0AevvDVCU2SnE1E r/LRu0z+yJMQ1BfSmJV29mi8PO/Di8e7NvrGs5hI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 359213858C1F; Thu, 10 Feb 2022 13:03:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 359213858C1F Received: by mail-wr1-x434.google.com with SMTP id f17so9505170wrx.1; Thu, 10 Feb 2022 05:03:55 -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=OmzOpNnSl2AY4xjmTmvZvHd1KoFnJUfQO6W+0QCbDhI=; b=6AaN/q5ty/uWrkruHkOwqCVBBVfgjIweEYPTHTIy/ED5cqaiB/uQZDVy9EObMTNutM WizwI33e3pENAjGh1n24qkem0dBvMi9wKfaj0xf1y3SR0pSxWWeDEc+ROA3QbRVbyt60 Q+XZg9DfiVbbxvsuGYr9lsv0LrlT3KM7eQWMfE038jpcUFL5m/WBSO+5R8yeLEBhA0LU MKATQEJzBqqi8oSDkdeA8OiV7SVqeAqFFxpbb6tki7yUQN/8A4Sgn0fxC0MYfafijfS8 9m5Nq5DGt81Z2PswXIWrYEyawsGWwx4HgsUvkSnb1NkMhLM2zNlOoW2gJe0jnGwDc7cp BGXA== X-Gm-Message-State: AOAM5321OFZCdixnUElhL6pgRDllhP7Sw4z8KeEfs/dZ4D8sC68aWBHY uYQCOaN/HHiB4wVFmQBhltRyd4WmX0YDxx2n+rY= X-Google-Smtp-Source: ABdhPJzf4L2a0a/k90UomUwA1XNfSfC0HLd2XvyeqFzsjknbWiJAbIullKomo/JiuH/eJ6xK/M7NouQpbnJY8euKD2A= X-Received: by 2002:a5d:4c86:: with SMTP id z6mr6261272wrs.568.1644498233923; Thu, 10 Feb 2022 05:03:53 -0800 (PST) MIME-Version: 1.0 References: <20220207201058.250114-1-dimitar@dinux.eu> In-Reply-To: Date: Thu, 10 Feb 2022 13:03:42 +0000 Message-ID: Subject: [committed] libstdc++: Decouple HAVE_FCNTL_H from HAVE_DIRENT_H check To: Dimitar Dimitrov X-Spam-Status: No, score=-7.0 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 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Cc: Jonathan Wakely , libstdc++ , gcc-patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On Tue, 8 Feb 2022 at 21:18, Jonathan Wakely wrote: > > > 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=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 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 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. > > Sorry for the delay, that's pushed to trunk now. commit 3d5f4f76e6db0895181ebca538748379bfe6058f Author: Jonathan Wakely Date: Tue Feb 8 21:05:30 2022 libstdc++: Fix directory iterator build for newlib When building for newlib HAVE_OPENAT and HAVE_UNLINKAT are (sometimes?) defined, but is only included when HAVE_DIRENT_H is defined. Since directory iterators are completely useless without , just override the HAVE_OPENAT and HAVE_UNLINKAT detection when we don't have . libstdc++-v3/ChangeLog: * src/filesystem/dir-common.h (_GLIBCXX_HAVE_DIRFD): Undefine when is not available. (_GLIBCXX_HAVE_UNLINKAT): Likewise. diff --git a/libstdc++-v3/src/filesystem/dir-common.h b/libstdc++-v3/src/filesystem/dir-common.h index 511b988f1c7..365fd527f4d 100644 --- 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