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 <[email protected]>
> ---
> 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
But as you say, doing it in meson might be even nicer (and that is also
beyond my meson-foo)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org