From patchwork Fri Jan 27 09:29:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 49130 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp739143wrn; Fri, 27 Jan 2023 01:31:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1Uasy2fiuNFa23KhiGNHQ9WqY+igHPcMqVBRkc3CwnPLIPlvZmXUVuBywgswVlazdUsXU X-Received: by 2002:a17:906:b009:b0:877:8ae7:2e44 with SMTP id v9-20020a170906b00900b008778ae72e44mr29968648ejy.5.1674811877023; Fri, 27 Jan 2023 01:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674811877; cv=none; d=google.com; s=arc-20160816; b=HtiEPJ61XgH27GDujs1y+d2d26l++EQVUraW1WzRt2u5Hvktk5Q2vQLgKWoNzy+o+i QVynL0NCWKo8FkUqKdJjnwbhM1gKKESK5qky3Fv270XHJN+cpbmdOSGCniX69FQT+S2D NWD8We6GOlVXdXSB0jvn993HZ3Ie0TzKhgeAu25wnIrF+QAFref3h5C5Xuqrp/QTx+S7 sbU+KUMngaG48AMYe4VCjKKpvXfPa8bgGuqdxQ4k9ma3CgPeKkhC25tYXbo9d+jPxSvR a4Guuge2cq9cLjbVAE39CMm/kuU3CwfKjrciWVxLI5j+Nap4ahUMavm/S0Dpvfhp5wSo blow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5lGT3wbX9ere8JmhB7u6/8In5T5JFsaScpk80E9+Vgk=; b=SmksGj4bwDV1ZEx8tXh7iNGiSfhYcsKwpVa80VwOy7u0jsDhNdP498pN32yaQzwday Olh2I6hcJIEih5u4irblkCPCwTzQrakQRzSjZZb0B2asog8+SZoQmm0LHYZOJNCdvh0/ 0iNqf+nVWLPB5bjYgxJOyj/BNOpWmVeIW48kLLU7gNm9QyS/PV52DfnohoGsEomk2++m O4nzNPMECE/CZ2ZWnq8/IM1C9uhosNpjBKfuur5R097YmfiUyTHcECEke44CDSxY7j5Q 36Vc1ZYs6DSKk17X1uqgP3zgLAhwqi5R9uSlwnAPSYuFCBZpNq+AVoSWFRjwVs4a6sFQ srRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ctfHcFGq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id mz13-20020a1709071b8d00b0087b9036951esi1965691ejc.837.2023.01.27.01.31.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 01:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ctfHcFGq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0ED333858408 for ; Fri, 27 Jan 2023 09:31:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ED333858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674811876; bh=5lGT3wbX9ere8JmhB7u6/8In5T5JFsaScpk80E9+Vgk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ctfHcFGqQ0JVi4qrdUqiogDXftngD379qj7l2QnairS1jzyvwn/ynVEgVwQOR+BgZ reJ3f+BpKEkYpnxIM6o3NdFti+FY9+qNIHAJ717VtcspuiksJzyIuES1995lNjSD/B jeATdLPEDnRfwDlL8O4w1eGHT4o98evHWprluzVU= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 412E33858D37 for ; Fri, 27 Jan 2023 09:29:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 412E33858D37 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-iSMqwafhMCG4_v6-X8YaXw-1; Fri, 27 Jan 2023 04:29:49 -0500 X-MC-Unique: iSMqwafhMCG4_v6-X8YaXw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7DFB800B30; Fri, 27 Jan 2023 09:29:48 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70E152026D4B; Fri, 27 Jan 2023 09:29:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30R9TkTs681981 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 27 Jan 2023 10:29:46 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30R9TjfE681980; Fri, 27 Jan 2023 10:29:45 +0100 Date: Fri, 27 Jan 2023 10:29:45 +0100 To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 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 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756167539114200360?= X-GMAIL-MSGID: =?utf-8?q?1756167539114200360?= Hi! On gcc112 which has glibc 2.17 I've noticed FAIL: 17_intro/names.cc (test for excess errors) FAIL: experimental/names.cc (test for excess errors) These are because glibc < 2.19 used __unused as field member of various structs, including mcontext_t in sys/ucontext.h on ppc64le. This was changed in glibc with https://gcc.gnu.org/pipermail/libc-alpha/2013-November/045766.html names.cc even has #ifdef __GLIBC_PREREQ #if ! __GLIBC_PREREQ(2, 19) // Glibc defines this prior to 2.19 #undef __unused #endif #endif for it, but it doesn't work. The reason is that __GLIBC_PREREQ is defined in but nothing included that header before this spot (it is included later from bits/stdc++.h). The following patch on Linux/Hurd conditionally includes features.h to get the needed macros before deciding if __unused should be undefined or not. If needed, I could use __GLIBC_PREREQ then but would need to check if it is defined and between 1996 and 1999 it wasn't. Tested on powerpc64le-linux with glibc 2.17 (where it fixes the regressions), on x86_64-linux with glibc 2.35 (where it still PASSes), plus on the latter with -E -dD on the test to verify __unused is just defined and not undefined later on, ok for trunk? 2023-01-27 Jakub Jelinek PR libstdc++/108568 * testsuite/17_intro/names.cc (__unused): For linux or GNU hurd include features.h if present and then check __GLIBC__ and __GLIBC_MINOR__ macros for glibc prior to 2.19, instead of testing __GLIBC_PREREQ which isn't defined yet. Jakub --- libstdc++-v3/testsuite/17_intro/names.cc.jj 2023-01-16 23:19:06.292716661 +0100 +++ libstdc++-v3/testsuite/17_intro/names.cc 2023-01-27 10:20:20.787645823 +0100 @@ -252,12 +252,15 @@ #undef y #endif -#ifdef __GLIBC_PREREQ -#if ! __GLIBC_PREREQ(2, 19) +#if defined (__linux__) || defined (__gnu_hurd__) +#if __has_include() +#include +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 19 // Glibc defines this prior to 2.19 #undef __unused #endif #endif +#endif #if __has_include() // newlib's defines these as macros.