* [PATCH] meson.build: Fix glib -Wno-unused-function workaround
@ 2023-05-24 17:31 Nicolas Saenz Julienne
2023-05-24 18:05 ` Philippe Mathieu-Daudé
2023-05-25 8:01 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Saenz Julienne @ 2023-05-24 17:31 UTC (permalink / raw)
To: pbonzini, philmd
Cc: marcandre.lureau, berrange, thuth, hilmd, qemu-devel,
Nicolas Saenz Julienne
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'])
glib_cflags += cc.get_supported_arguments('-Wno-unused-function')
endif
glib = declare_dependency(dependencies: [glib_pc, gmodule],
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] meson.build: Fix glib -Wno-unused-function workaround
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é
2023-05-25 8:01 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-05-24 18:05 UTC (permalink / raw)
To: Nicolas Saenz Julienne, pbonzini
Cc: marcandre.lureau, berrange, thuth, hilmd, qemu-devel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] meson.build: Fix glib -Wno-unused-function workaround
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é
@ 2023-05-25 8:01 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2023-05-25 8:01 UTC (permalink / raw)
To: Nicolas Saenz Julienne
Cc: pbonzini, philmd, marcandre.lureau, berrange, thuth, hilmd, qemu-devel
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-25 8:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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é
2023-05-25 8:01 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.