From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id v2zbKarakl+dYQAAWB0awg (envelope-from ) for ; Fri, 23 Oct 2020 09:29:14 -0400 Received: by simark.ca (Postfix, from userid 112) id 9DC7C1EE09; Fri, 23 Oct 2020 09:29:14 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=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 C79581E58D for ; Fri, 23 Oct 2020 09:29:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53EEF3857024; Fri, 23 Oct 2020 13:29:13 +0000 (GMT) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by sourceware.org (Postfix) with ESMTPS id 87F0B3858022 for ; Fri, 23 Oct 2020 13:29:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87F0B3858022 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f66.google.com with SMTP id c16so1566236wmd.2 for ; Fri, 23 Oct 2020 06:29:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2N7bc6vY3iS3/IZQXSJeUxKIapoR7PxEs1Qfoq8mUuY=; b=USSi/ePC4cVpO3UhcByHwoSGM1J2+mBG+wx8KMut1MB23Nh6RFBcsIPL6Ug3eVekCH LOcIko/977NMWmnr3Dwbr09ce/KlaRDV72boo405T1rQwKgGYFxH8HMHU+zg4aJGJ4lV 289FS92nzfP3hQKXW888jNub0f1bNAlC19HwEn9/AsSoFIQOliDuWYTECzoPHbCnxqNk ML7RH4GPIOnlFuBFDBkhwQQfnXGibTbcdPQFy7Uv3gKQRGR7Fp8w7+N03NTGzQOfh09L ujI11crQmRkdkXHLMZ39i+9cOsFtcVSKpbM0rI1CGJeU216H19q0kqQU14duQY9Wdnk7 vpvA== X-Gm-Message-State: AOAM53359RB6/M5hwROCIpiCmj314v+ximhbGlBvBRonz/1sAUbb3MFP 7MFtXvnalswTgQR069Kr2HFQXo3h6vVhNg== X-Google-Smtp-Source: ABdhPJyqH6TMzYtxQzSNyIfaykSmctQ7Ldhjh3Q/XmMbkGJDIFMQ0v8B21mmXujFuAEhLUbtaFzAlQ== X-Received: by 2002:a1c:7f97:: with SMTP id a145mr2432350wmd.160.1603459748993; Fri, 23 Oct 2020 06:29:08 -0700 (PDT) Received: from ?IPv6:2001:8a0:f91e:6d00:f223:ef68:24e0:af8f? ([2001:8a0:f91e:6d00:f223:ef68:24e0:af8f]) by smtp.gmail.com with ESMTPSA id 133sm3519762wmb.2.2020.10.23.06.29.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 06:29:07 -0700 (PDT) Subject: Re: [PATCH] Fix testcases using __attribute__((noclone)) with Clang To: Gary Benson , gdb-patches@sourceware.org References: <1600272360-20954-1-git-send-email-gbenson@redhat.com> From: Pedro Alves Message-ID: <5b045172-9175-e20d-ceff-89c3d44953a0@palves.net> Date: Fri, 23 Oct 2020 14:29:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1600272360-20954-1-git-send-email-gbenson@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 9/16/20 5:06 PM, Gary Benson via Gdb-patches wrote: > Hi all, > > 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 > +