From patchwork Tue Jul 23 09:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1963707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZS4WK3WL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WSskS1LlRz1yYm for ; Tue, 23 Jul 2024 19:47:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E361386181E for ; Tue, 23 Jul 2024 09:47:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 2B5D5385E459 for ; Tue, 23 Jul 2024 09:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B5D5385E459 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 2B5D5385E459 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=1721727999; cv=none; b=c/4gzEyLfiMzbbbZ9VdRx7WlKr2AvM6IVxTOgNrxFmDMu3/NQ/OoGe8vF6eZpstZ6R7+Px+Yo6Xa1AkoG6CsR+NW2hXOf+4SwbsPCWK5FiGNOd07wkrEU5O1L2ZwhAE7jBAra+VFsGY6lCY3K9IYM1KQ/znKxLDqv78DuRdwdxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721727999; c=relaxed/simple; bh=Wm2G+pjNXQodolr1kE1yPqDXOq2uQdnK/+pQDgj0ltE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IcimPpT3h1wsySr8ZfvRbveA1ComEf6oXojTdDhQEV5LVeMorxn4k5J9eNmNY4eNwfngnPmaD/NHICIVKgoEgnTKSZ68Xw3lCQqv0XN+ZSczouB2BXvziZe4lmCMJQmJul5AWxzlR0ye86UAIe+r9tkVuMwGd6hhMnDPmqsI44o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721727997; h=from:from: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; bh=Q74ijcBO+xB8soUbqN2JCJsGX/Fzg3wIN3iExU+Mjvk=; b=ZS4WK3WLL883xaB2J6E7oIQUaLkf95H92WS2oo9kTq3WDLXZzD8u63RgpJp/S/0dlCY6VI cIPHVqm6mAVNwYqiiEVX0Zv+gVaGBDjfey2TFFBjS6x4haz0c9aUgfNWxwmmWxXVZJ2hho CUy+ahw5eFNIBrY73a40plJrakytacA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-JLI29fTnOjiiS6oaOIWY9A-1; Tue, 23 Jul 2024 05:46:34 -0400 X-MC-Unique: JLI29fTnOjiiS6oaOIWY9A-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF61C19560AA; Tue, 23 Jul 2024 09:46:32 +0000 (UTC) Received: from localhost (unknown [10.42.28.14]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C43063000192; Tue, 23 Jul 2024 09:46:30 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Detlef Vollmann Subject: [committed] libstdc++: Do not use isatty on avr [PR115482] Date: Tue, 23 Jul 2024 10:38:07 +0100 Message-ID: <20240723094629.3664516-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org I'm pushing this workaround from Detlef. I incorrectly assumed that is enough to ensure isatty is present, but that isn't true for avr-libc. It might be cleaner to add a proper autoconf check for isatty and dup, but we don't have any reports of it failing for other targets. This simple workaround solves the immediate problem in time for the 14.2 release. Apart from using __write_to_terminal in the 27_io/print/2.cc test, the functions in this file are not actually used for non-Windows targets. As long as they compile and don't break the build, that's good enough. Tested x86_64-linux, built on avr and mingw-w64. Pushed to trunk, gcc-14 backport when testing finishes. -- >8 -- avrlibc has an incomplete unistd.h that doesn't have isatty. So building libstdc++ fails when compiling c++23/print.cc. As a workaround I added a check for AVR. libstdc++-v3/ChangeLog: PR libstdc++/115482 * src/c++23/print.cc (__open_terminal) [__AVR__]: Do not use isatty. --- libstdc++-v3/src/c++23/print.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++23/print.cc b/libstdc++-v3/src/c++23/print.cc index 99a19cd4500..558dc149d12 100644 --- a/libstdc++-v3/src/c++23/print.cc +++ b/libstdc++-v3/src/c++23/print.cc @@ -75,7 +75,7 @@ namespace #ifdef _WIN32 if (int fd = ::_fileno(f); fd >= 0) return check_for_console((void*)_get_osfhandle(fd)); -#elifdef _GLIBCXX_HAVE_UNISTD_H +#elif defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__ if (int fd = (::fileno)(f); fd >= 0 && ::isatty(fd)) return f; #endif @@ -100,7 +100,7 @@ namespace #ifdef _WIN32 if (auto fb = dynamic_cast(sb)) return check_for_console(fb->native_handle()); -#elifdef _GLIBCXX_HAVE_UNISTD_H +#elif defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__ if (auto fb = dynamic_cast(sb)) if (int fd = fb->native_handle(); fd >= 0 && ::isatty(fd)) return ::fdopen(::dup(fd), "w"); // Caller must call fclose.