From: Eric Blake Date: Tue, 17 Mar 2020 17:55:34 +0000 (-0500) Subject: build: Silence clang warning on older glib autoptr usage X-Git-Tag: v5.0.0-rc0~19^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9bda600b0833821685e23068e50be5134dc0ab05;p=thirdparty%2Fqemu.git build: Silence clang warning on older glib autoptr usage glib's G_DEFINE_AUTOPTR_CLEANUP_FUNC() macro defines several static inline functions, often with some of them unused, but prior to 2.57.2 did not mark the functions as such. As a result, clang (but not gcc) fails to build with older glib unless -Wno-unused-function is enabled. Reported-by: Peter Maydell Signed-off-by: Eric Blake Reviewed-by: John Snow Message-id: 20200317175534.196295-1-eblake@redhat.com Signed-off-by: John Snow --- diff --git a/configure b/configure index 06fcd070fb3..479336bf6e3 100755 --- a/configure +++ b/configure @@ -3851,6 +3851,26 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then fi fi +# Silence clang warnings triggered by glib < 2.57.2 +cat > $TMPC << EOF +#include +typedef struct Foo { + int i; +} Foo; +static void foo_free(Foo *f) +{ + g_free(f); +} +G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); +int main(void) { return 0; } +EOF +if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then + if cc_has_warning_flag "-Wno-unused-function"; then + glib_cflags="$glib_cflags -Wno-unused-function" + CFLAGS="$CFLAGS -Wno-unused-function" + fi +fi + ######################################### # zlib check