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 <peter.mayd...@linaro.org> Signed-off-by: Eric Blake <ebl...@redhat.com> --- Half-tested: I proved to myself that this does NOT enable -Wno-unused-function on my setup of glib 2.62.5 and gcc 9.2.1 (Fedora 31), but would do so if I introduced an intentional compile error into the sample program; but Iwas unable to test that it would prevent the build failure encountered by Peter on John's pull request (older glib but exact version unknown, clang, on NetBSD). configure | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/configure b/configure index eb49bb6680c1..57a72f120aa9 100755 --- a/configure +++ b/configure @@ -3832,6 +3832,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 <glib.h> +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 -- 2.25.1