qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, berrange@redhat.com
Subject: Re: [PATCH] build: Silence clang warning on older glib autoptr usage
Date: Tue, 17 Mar 2020 14:01:55 -0400	[thread overview]
Message-ID: <83d2ae9e-7754-e411-27f2-0e5bda853107@redhat.com> (raw)
In-Reply-To: <20200317175534.196295-1-eblake@redhat.com>



On 3/17/20 1:55 PM, Eric Blake wrote:
> 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.maydell@linaro.org>
> Signed-off-by: Eric Blake <eblake@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
> 

This looks good to me. By using the glib function under question as the
test program we disable the warning only on some very limited cases.

This might silence SOME legitimate code hygiene warnings so long as
older glib is being used, but there's simply nothing we can do to
prevent this unless glibc is updated on those machines.

Unfortunately, I do not have a NetBSD machine at present, nor do I have
enough familiarity with that platform to make any informed decisions
about if we can say:

- NetBSD is only supported when using glibc XXX and newer

because I do not know if we support any NetBSD platforms that do not
have the updated library in their package repositories.

So, given all of that, this is the most targeted fix that I am able to
reason about at present, so:

Reviewed-by: John Snow <jsnow@redhat.com>



  reply	other threads:[~2020-03-17 18:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 17:55 [PATCH] build: Silence clang warning on older glib autoptr usage Eric Blake
2020-03-17 18:01 ` John Snow [this message]
2020-03-17 18:11 ` Peter Maydell
2020-03-18 11:19   ` Eric Blake
2020-03-18 12:45     ` Eric Blake
2020-03-18 12:55   ` Eric Blake
2020-03-18 17:18     ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83d2ae9e-7754-e411-27f2-0e5bda853107@redhat.com \
    --to=jsnow@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).