From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jDs5MPP3n19qDQAAWB0awg (envelope-from ) for ; Mon, 02 Nov 2020 07:13:39 -0500 Received: by simark.ca (Postfix, from userid 112) id B82E91F08B; Mon, 2 Nov 2020 07:13:39 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 simark.ca (Postfix) with ESMTPS id 122BF1E58E for ; Mon, 2 Nov 2020 07:13:39 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 839043858005; Mon, 2 Nov 2020 12:13:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 839043858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604319218; bh=3iW2kcS4uRK+O42t0BKxdtb1oQhuuJ+VY9+TOZPyOyI=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=yEabnOE/HomvrLHHF2tNHYGHaTWJjTo3++gEbOrNxSfCnkgMrc3r7dXu1T+iuwdcn HgrfckB58NJFTmi5EGMwdCuySK8MRO/XLqbskfSBGRYRQj6EZILJ4kp1oPEVnVPp5K xLFZnIq8MgV16+caP1iTir527rOksVLQEkb273oY= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id C34753858005 for ; Mon, 2 Nov 2020 12:13:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C34753858005 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-WMuAwHApMr2015JuxDZ3UA-1; Mon, 02 Nov 2020 07:13:31 -0500 X-MC-Unique: WMuAwHApMr2015JuxDZ3UA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFD0C10E2186; Mon, 2 Nov 2020 12:13:30 +0000 (UTC) Received: from blade.nx (ovpn-115-15.ams2.redhat.com [10.36.115.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90FD57366D; Mon, 2 Nov 2020 12:13:30 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id C17A3816CD2E; Mon, 2 Nov 2020 12:13:29 +0000 (GMT) Date: Mon, 2 Nov 2020 12:13:29 +0000 To: Pedro Alves Subject: [PUSHED] Fix testcases using __attribute__((noclone)) with Clang Message-ID: <20201102121329.GA20497@blade.nx> References: <1600272360-20954-1-git-send-email-gbenson@redhat.com> <5b045172-9175-e20d-ceff-89c3d44953a0@palves.net> MIME-Version: 1.0 In-Reply-To: <5b045172-9175-e20d-ceff-89c3d44953a0@palves.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gary Benson via Gdb-patches Reply-To: Gary Benson Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi Pedro, Sorry for the random email I just sent, git-send-email fired it off before I was ready! What it *should* have said was: Thank you for the review. I've updated my patch with your suggestion. Also, I interpreted your "I think this would work" to mean you hadn't tested it, so I dug out a copy of GCC 4.8 and checked the preprocessor conditionals were doing the right thing (they were). Cheers, Gary Pedro Alves wrote: > On 9/16/20 5:06 PM, Gary Benson via Gdb-patches wrote: > > Clang fails to compile a number of files with the following warning: > > unknown attribute 'noclone' ignored [-Wunknown-attributes]. This > > commit adds a new header, lib/noclone.h, which defines the macro > > ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases > > to use it. > > > diff --git a/gdb/testsuite/lib/noclone.h b/gdb/testsuite/lib/noclone.h > > new file mode 100644 > > index 0000000..b6a4aa7 > > --- /dev/null > > +++ b/gdb/testsuite/lib/noclone.h > > I'd think that if you need to handle one attribute, > you'll soon enough need to handle other attributes. > Thus, I'd call this header something more generic like attributes.h. > > > + > > +/* Compatibility macro for __attribute__((noclone)). */ > > + > > +#ifndef NOCLONE_H > > +#define NOCLONE_H > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#if __has_attribute(noclone) > > __has_attribute isn't universally available. For GCC, it was > only added on GCC 5: > > https://gcc.gnu.org/gcc-5/changes.html > > We support building GDB with GCC 4.8. And the set of compilers the > testsuite can be run against is larger than the set of compilers GDB > builds with -- consider cross compilers for embedded targets, > for example. > > So we need to handle __has_attribute not being defined. I think > this would work: > > #ifdef __has_attribute > # if !__has_attribute (noclone) > # define ATTRIBUTE_NOCLONE > # endif > #endif > #ifndef ATTRIBUTE_NOCLONE > # define ATTRIBUTE_NOCLONE __attribute__((noclone)) > #endif > > > +# define ATTRIBUTE_NOCLONE __attribute__((noclone)) > > +#else > > +# define ATTRIBUTE_NOCLONE > > +#endif > > + > > +#ifdef __cplusplus > > +} > > +#endif > > +