qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH v2 00/15] qapi: add #if pre-processor condit


From: Markus Armbruster
Subject: Re: [Qemu-devel] [RFC PATCH v2 00/15] qapi: add #if pre-processor conditions to generated code (part 3)
Date: Wed, 19 Dec 2018 09:57:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Marc-André Lureau <address@hidden> writes:

> Hi
>
> On Tue, Dec 18, 2018 at 10:26 PM Markus Armbruster <address@hidden> wrote:
>>
>> Marc-André posted v1 that relies on a QAPI schema language extension
>> 'top-unit' to permit splitting the generated code.  Here is his cover
>> letter:
>>
>>     The thrid and last part (of "[PATCH v2 00/54] qapi: add #if
>>     pre-processor conditions to generated code") is about adding schema
>>     conditions based on the target.
>>
>>     For now, the qapi code is compiled in common objects (common to all
>>     targets). This makes it impossible to add #if TARGET_ARM for example.
>>
>>     The patch "RFC: qapi: learn to split the schema by 'top-unit'"
>>     proposes to split the schema by "top-unit", so that generated code can
>>     be built either in common objects or per-target. That patch is a bit
>>     rough, I would like to get some feedback about the approach before
>>     trying to improve it. The following patches demonstrate usage of
>>     target-based #if conditions, and getting rid of the
>>     qmp_unregister_command() hack.
>>
>> We already have a way to split generated code: QAPI modules.  I took
>> the liberty to rework Marc-André's series to use a target module
>> instead.  Less code, no change to the QAPI language.
>>
>> One of the patches (marked WIP) is a total hack.  Fixable, but I want
>> to get this out for discussion first.
>
> The approach you propose includes -target.h header in the top headers,
> effectively making all the qapi code target-dependent, no?

Yes, but...

> I am actually a bit surprised there are no poisoined define errors.
> Possibly because the top-level header is rarely included.

... next to nothing includes the top-level header:

    $ git-grep -E 'include.*"(qapi/)?qapi-[^-]*.h'
    monitor.c:#include "qapi/qapi-commands.h"

Here we actually need all commands, complete with their
target-dependence.

    monitor.c:#include "qapi/qapi-introspect.h"
    tests/test-qobject-input-visitor.c:#include "qapi/qapi-introspect.h"

qapi-introspect.[ch] are monolithic.

    ui/cocoa.m:#include "qapi/qapi-commands.h"

This is just lazy; we should include just the qapi-commands-FOO we
actually need.  I'll ask the maintainer for help with cleaning this up.

Including top-level headers has been a bad idea ever since we generate
modular headers (commit 252dc3105fc), because it leads to "touch the
QAPI schema, have some coffee while the world is recompiled".

Adding target-dependent conditionals makes this bad idea impractical in
target-independent code.  Feature!

> By contrast, my approach has the advantage of a clean split between
> target and non-target dependent code, which I would feel more
> confident about.
>
> That's the reason why I promptly discarded the QAPI modules approach
> without having second thoughts at least. Now you force me to
> reconsider it though.

Please do :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]