From f49d883d4de4011365ca3644fcd1914df5193227 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 24 May 2023 17:31:23 +0000 Subject: meson.build: Fix glib -Wno-unused-function workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230524173123.66483-1-nsaenz@amazon.com> Signed-off-by: Paolo Bonzini --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 0a5cdef..448b71a 100644 --- a/meson.build +++ b/meson.build @@ -770,7 +770,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], -- cgit v1.1 From b03fcd6818f690d168860f895bc9e8eab971d6de Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 22 May 2023 10:05:33 +0200 Subject: meson: move -no-pie from linker to compiler The large comment in the patch says it all; the -no-pie flag is broken and this is why it was not included in QEMU_LDFLAGS before commit a988b4c5614 ("build: move remaining compiler flag tests to meson", 2023-05-18). And some distros made things even worse, so we have to add it to the compiler command line. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1664 Signed-off-by: Paolo Bonzini --- meson.build | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 448b71a..2e47608 100644 --- a/meson.build +++ b/meson.build @@ -265,12 +265,21 @@ endif # Meson currently only handles pie as a boolean for now, so if the user # has explicitly disabled PIE we need to extend our cflags. +# +# -no-pie is supposedly a linker flag that has no effect on the compiler +# command line, but some distros, that didn't quite know what they were +# doing, made local changes to gcc's specs file that turned it into +# a compiler command-line flag. +# +# What about linker flags? For a static build, no PIE is implied by -static +# which we added above (and if it's not because of the same specs patching, +# there's nothing we can do: compilation will fail, report a bug to your +# distro and do not use --disable-pie in the meanwhile). For dynamic linking, +# instead, we can't add -no-pie because it overrides -shared: the linker then +# tries to build an executable instead of a shared library and fails. So +# don't add -no-pie anywhere and cross fingers. :( if not get_option('b_pie') - qemu_common_flags += cc.get_supported_arguments('-fno-pie') - if not get_option('prefer_static') - # No PIE is implied by -static which we added above. - qemu_ldflags += cc.get_supported_link_arguments('-no-pie') - endif + qemu_common_flags += cc.get_supported_arguments('-fno-pie', '-no-pie') endif if not get_option('stack_protector').disabled() -- cgit v1.1