From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 87EFF3858C98 for ; Mon, 12 Feb 2024 16:33:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87EFF3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 87EFF3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707755614; cv=none; b=BVF67B10bRQn7y5/JSC/8rUE1ie9Q2pDykOWvUr0ncIufCMoxw24WOnghBRsBI2rEKjqZwXlj9edsRgM1LZNSysaecOIxDsjEgKmjkecZm7HRNsfGJ0IJO8B3a/vPHw/+pJNr8BEvVfmMnnHvj9h0Q/sPFEYMwsv3Mh5UWkRsJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707755614; c=relaxed/simple; bh=S/xbk1hD0ZY0vPZPnK+TPlTkzVg2eMGY9MjCoKqp/Lc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=wOy9/OuHquXCxwzZebekpPeQYncB+CFSM21ISWoFQFz5UyXmKBq2SjBNRbLv4Sszc4KSUKnStCekdFZtti3EuvD9SjTP1mDzu6ZsB7ZBkhHmnk67LwriUvg6prGrBykhalUW5Epxzc5rRxY5rLxhTWTWy3GA4mscAsMgl2vnMuM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707755612; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lHBPNNA8771DyRPe77QbYUYjL/YqVlXkh0vx32KBMxE=; b=M/Zz21Z3d2LQIeZgZD3oDUiRLnmq323rU3tqUcWOXlHEc03gnyDNSnILAxp7dYJvqow/GX gL5gSZbnxjt6kxpEe13ADEQAoSVkaU/VtrfxcgOd+x/Yr9unMJKo9XoByPg7sDlTPgiTk3 VCj32NrlCNWf0NkJyTJj44RvYI+FUPc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-6AE6J1yOMKqP1xxdYzD3IQ-1; Mon, 12 Feb 2024 11:33:28 -0500 X-MC-Unique: 6AE6J1yOMKqP1xxdYzD3IQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A60C101FA3A; Mon, 12 Feb 2024 16:33:28 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.195.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67E3D1121C; Mon, 12 Feb 2024 16:33:28 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 2CDEDA80385; Mon, 12 Feb 2024 17:33:27 +0100 (CET) Date: Mon, 12 Feb 2024 17:33:27 +0100 From: Corinna Vinschen To: Torbjorn SVENSSON Cc: Andrew Pinski , Newlib , Yvan Roux Subject: Re: Mismatch between newlib and glibc regarding fileno Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Torbjorn SVENSSON , Andrew Pinski , Newlib , Yvan Roux References: <52858367-f116-413e-b107-61c8afce156b@foss.st.com> <42f199ba-8905-4846-9768-54342244610e@foss.st.com> MIME-Version: 1.0 In-Reply-To: <42f199ba-8905-4846-9768-54342244610e@foss.st.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Feb 12 16:36, Torbjorn SVENSSON wrote: > On 2024-02-09 17:54, Corinna Vinschen wrote: > > On Feb 9 08:40, Andrew Pinski wrote: > > > On Fri, Feb 9, 2024 at 8:30 AM Torbjorn SVENSSON > > > wrote: > > > > > > > > Hi all, > > > > > > > > I've been trying to run tests for arm-none-eabi on GCC14 tree. > > > > What I've seen is that fileno() is not available. If you look though the > > > > header files, I see that this is guarded by __POSIX_VISIBLE and due to a > > > > recent change in the GCC testsuite (part of PR96395), they moved the > > > > test case to gcc/testsuite/c-c++-common/analyzer/fileno-1.c and then > > > > invoke it with g++ and -std=c++98. With this change, strict ANSI is > > > > defined, but not __POSIX_VISIBLE. > > > > > > Note the testcase failure is recorded as https://gcc.gnu.org/PR113278 . > > > > > > > > > > > If I run the same test on the native g++ tool in Ubuntu, I instead get > > > > that __USE_POSIX is set (the guard for fileno() in glibc), so this > > > > differs from the behavior noticed with newlib. > > > > > > That is also due to _GNU_SOURCE being defined for C++ for Linux/g++. I > > > think this is just a GCC testcase issue rather than something needing > > > to be fixed in newlib even. > > > > Along these lines, note the Linux man page for fileno: > > > > STANDARDS > > POSIX.1-2008. > > > > HISTORY > > POSIX.1-2001. > > > > and the feature test in GLibc's stdio.h: > > > > #ifdef __USE_POSIX > > /* Return the system file descriptor for STREAM. */ > > extern int fileno (FILE *__stream) __THROW __wur; > > #endif /* Use POSIX. */ > > > > > > Corinna > > > Okay, so newlib is more restrictive than glibc on this topic. > I will prepare a patch for test cases in GCC with defining _POSIX_SOURCE so > that the test cases succeed for newlib. It looks like it. But I do wonder if that's really intended by glibc. I ran a quick test, first under newlibL $ g++ -std=c++98 -E -dM /usr/include/features.h | grep VISIBLE #define __LARGEFILE_VISIBLE 0 #define __ISO_C_VISIBLE 1999 #define __XSI_VISIBLE 0 #define __GNU_VISIBLE 0 #define __BSD_VISIBLE 0 #define __POSIX_VISIBLE 0 #define __SVID_VISIBLE 0 #define __ATFILE_VISIBLE 0 #define __MISC_VISIBLE 0 then under glibc: $ g++ -std=c++98 -E -dM x.cc | grep '#define __USE' #define __USE_UNIX98 1 #define __USE_FORTIFY_LEVEL 0 #define __USE_ISOC11 1 #define __USE_ISOC95 1 #define __USE_ISOC99 1 #define __USE_XOPEN 1 #define __USE_XOPEN2K 1 #define __USE_POSIX199506 1 #define __USE_GNU 1 #define __USE_XOPEN2KXSI 1 #define __USE_XOPEN2K8 1 #define __USE_POSIX 1 #define __USER_LABEL_PREFIX__ #define __USE_MISC 1 #define __USE_POSIX2 1 #define __USE_LARGEFILE64 1 #define __USE_POSIX199309 1 #define __USE_XOPEN2K8XSI 1 #define __USE_LARGEFILE 1 #define __USE_XOPEN_EXTENDED 1 #define __USE_DYNAMIC_STACK_SIZE 1 #define __USE_ATFILE 1 How is it possible that with -std=c++98, everything and the kitchen sink is enabled? Is that really correct?!? Corinna