From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Nicolas Saenz Julienne <nsaenz@amazon.com>, pbonzini@redhat.com
Cc: marcandre.lureau@redhat.com, berrange@redhat.com,
thuth@redhat.com, hilmd@linaro.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] meson.build: Fix glib -Wno-unused-function workaround
Date: Wed, 24 May 2023 20:05:33 +0200 [thread overview]
Message-ID: <f87ac9d2-8eb7-6a5f-9f41-2d615fe9a40a@linaro.org> (raw)
In-Reply-To: <20230524173123.66483-1-nsaenz@amazon.com>
On 24/5/23 19:31, Nicolas Saenz Julienne wrote:
> We want to only enable '-Wno-unused-function' if glib's version is
> smaller than '2.57.2' and has a G_DEFINE_AUTOPTR_CLEANUP_FUNC()
> implementation that doesn't take into account unused functions. But the
> compilation test isn't working as intended as '-Wunused-function' isn't
> enabled while running it.
>
> Let's enable it.
>
> Fixes: fc9a809e0d28 ("build: move glib detection and workarounds to meson")
> Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com>
>
> ---
>
> Meson logs before:
>
> Running compile:
> Working directory: /local/home/nsaenz/c/qemu/build/meson-private/tmp5fgb3xnk
> Command line: clang -m64 -mcx16 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include /local/home/nsaenz/c/qemu/build/meson-private/tmp5fgb3xnk/testfile.c -o /local/home/nsaenz/c/qemu/build/meson-private/tmp5fgb3xnk/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=gnu11 -Werror
>
> Code:
>
> #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; }
> Compiler stdout:
>
> Compiler stderr:
>
>
> Meson logs after:
>
> Running compile:
> Working directory: /local/home/nsaenz/c/qemu/build/meson-private/tmp1fnp2s4u
> Command line: clang -m64 -mcx16 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include /local/home/nsaenz/c/qemu/build/meson-private/tmp1fnp2s4u/testfile.c -o /local/home/nsaenz/c/qemu/build/meson-private/tmp1fnp2s4u/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=gnu11 -Wunused-function -Werror
>
> Code:
>
> #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; }
> Compiler stdout:
>
> Compiler stderr:
> /local/home/nsaenz/c/qemu/build/meson-private/tmp1fnp2s4u/testfile.c:10:3: error: unused function 'glib_autoptr_cleanup_Foo' [-Werror,-Wunused-function]
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
> ^
> /usr/include/glib-2.0/glib/gmacros.h:461:22: note: expanded from macro 'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
> static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
> ^
> /usr/include/glib-2.0/glib/gmacros.h:441:43: note: expanded from macro '_GLIB_AUTOPTR_FUNC_NAME'
> #define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
> ^
> <scratch space>:58:1: note: expanded from here
> glib_autoptr_cleanup_Foo
> ^
>
> meson.build | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index ef181ff2df..71a4fcee52 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -780,7 +780,7 @@ if not cc.compiles('''
> g_free(f);
> }
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
> - int main(void) { return 0; }''', dependencies: glib_pc, args: ['-Werror'])
> + int main(void) { return 0; }''', dependencies: glib_pc, args: ['-Wunused-function', '-Werror'])
Oops, thanks!
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2023-05-24 18:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 17:31 [PATCH] meson.build: Fix glib -Wno-unused-function workaround Nicolas Saenz Julienne
2023-05-24 18:05 ` Philippe Mathieu-Daudé [this message]
2023-05-25 8:01 ` Paolo Bonzini
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=f87ac9d2-8eb7-6a5f-9f41-2d615fe9a40a@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=hilmd@linaro.org \
--cc=marcandre.lureau@redhat.com \
--cc=nsaenz@amazon.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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).