qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH] configure: Poison (almost) all target-specific #defines
Date: Tue, 16 Mar 2021 06:28:14 +0100	[thread overview]
Message-ID: <1d8f79e6-c8b7-b9a4-4af4-7a48e999d5cd@redhat.com> (raw)
In-Reply-To: <1a8dc3e5-0d8e-e52b-897d-69d0b2e28fd4@redhat.com>

On 15/03/2021 19.24, Eric Blake wrote:
> On 3/15/21 8:54 AM, Thomas Huth wrote:
>> We are generating a lot of target-specific defines in the *-config-devices.h
>> and *-config-target.h files. Using them in common code is wrong and leads
>> to very subtle bugs since a "#ifdef CONFIG_SOMETHING" is not working there
>> as expected. To avoid these issues, we are already poisoning some of the
>> macros in include/exec/poison.h - but maintaining this list manually is
>> cumbersome. Thus let's generate the list of poisoned macros automatically
>> instead.
>> Note that CONFIG_TCG (which is also defined in config-host.h) and
>> CONFIG_USER_ONLY are special, so we have to filter these out.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   RFC since the shell stuff in "configure" is quite ugly ... maybe there's
>>   a better way to do this via meson, but my meson-foo is still lacking...
>>
> 
>> +++ b/configure
>> @@ -6441,6 +6441,11 @@ if test -n "${deprecated_features}"; then
>>       echo "  features: ${deprecated_features}"
>>   fi
>>   
>> +cat *-config-devices.h *-config-target.h | grep '^#define '  \
>> +    | grep -v CONFIG_TCG | grep -v CONFIG_USER_ONLY \
>> +    | sed -e 's/#define //' -e 's/ .*//' | sort -u \
>> +    | sed -e 's/^/#pragma GCC poison /' > config-poison.h
> 
> Most times, a 'grep | sed' pipeline can be rewritten in pure sed.  In
> this case:
> 
> cat *-config-devices.h *-config-target.h | \
>    sed -n -e '/^#define / { s///; /CONFIG_TCG/d; /CONFIG_USER_ONLY/d;' \
>           -e 's/ .*//; s/^/#pragma GCC poison /p; }' | \
>    sort -u > config-poison.h

Thanks! I'll update my patch and use your suggestion (unless someone comes 
up with some Meson magic to do it there instead)

  Thomas




      reply	other threads:[~2021-03-16  5:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 13:54 [RFC PATCH] configure: Poison (almost) all target-specific #defines Thomas Huth
2021-03-15 14:07 ` Claudio Fontana
2021-03-15 15:08   ` Thomas Huth
2021-03-15 15:22     ` Claudio Fontana
2021-03-15 14:52 ` Philippe Mathieu-Daudé
2021-03-15 15:24   ` Thomas Huth
2021-03-15 15:37     ` Peter Maydell
2021-03-15 15:52       ` Thomas Huth
2021-03-15 18:24 ` Eric Blake
2021-03-16  5:28   ` Thomas Huth [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=1d8f79e6-c8b7-b9a4-4af4-7a48e999d5cd@redhat.com \
    --to=thuth@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).