On 4/8/21 3:56 AM, Claudio Fontana wrote:
It is a struggle to balance making TCG-only symbols "invisible" to kvm-builds,
so one developing for KVM only can forget about them,
and keeping TCG things contained,
and on the other side opening up the ability to use tcg_enabled(), which
requires those prototypes to be visible.
Where do you see that balance?
The short answer is I'd keep the prototypes available, always.
The longer answer is that I'd make more use of QEMU_ERROR().
I think I described this off-hand before, but let me develop this thought more
completely. Let's put some defines in a handy common header file:
#ifdef CONFIG_TCG
#define REQUIRE_TCG
#else
#define REQUIRE_TCG QEMU_ERROR("tcg function is reachable")
#endif
and so on for all of the other accelerators, as well as
#ifdef CONFIG_USER_ONLY
#define REQUIRE_USER_ONLY
#define REQUIRE_SYSEMU QEMU_ERROR("sysemu function is reachable")
#else
#define REQUIRE_USER_ONLY \
QEMU_ERROR("user-only function is reachable")
#define REQUIRE_SYSEMU
#endif
Then, in target/foo/bar.h, instead of
#ifdef CONFIG_TCG
void some_function(...);
#endif
we write
void some_function(...) REQUIRE_TCG;
which is self-documentary, and also generates a compile error when the function
call has not been eliminated by a guard such as tcg_enabled (as opposed to
waiting until link time for the missing symbol).
r~