From: Gary Benson via Gdb-patches <gdb-patches@sourceware.org>
To: Pedro Alves <pedro@palves.net>
Cc: gdb-patches@sourceware.org
Subject: [PUSHED] Fix testcases using __attribute__((noclone)) with Clang
Date: Mon, 2 Nov 2020 12:13:29 +0000 [thread overview]
Message-ID: <20201102121329.GA20497@blade.nx> (raw)
In-Reply-To: <5b045172-9175-e20d-ceff-89c3d44953a0@palves.net>
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
> > +
prev parent reply other threads:[~2020-11-02 12:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 16:06 [PATCH] " Gary Benson
2020-09-30 10:02 ` [PING][PATCH] " Gary Benson via Gdb-patches
2020-10-14 9:27 ` [PING^2][PATCH] " Gary Benson via Gdb-patches
2020-10-23 13:29 ` [PATCH] " Pedro Alves
2020-11-02 11:58 ` Gary Benson via Gdb-patches
2020-11-02 12:13 ` Gary Benson via Gdb-patches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201102121329.GA20497@blade.nx \
--to=gdb-patches@sourceware.org \
--cc=gbenson@redhat.com \
--cc=pedro@palves.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox