From: Pierrick Bouvier Date: Wed, 31 Dec 2025 02:47:23 +0000 (-0800) Subject: meson: fix supported compiler arguments in other languages than C X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=329803c111229f8b893bf455db5669dde879d7c1;p=thirdparty%2Fqemu.git meson: fix supported compiler arguments in other languages than C qemu_common_flags are only checked for c compiler, even though they are applied to c++ and objc. This is a problem when C compiler is gcc, and C++ compiler is clang, creating a possible mismatch. One concrete example is option -fzero-call-used-regs=used-gpr with ubuntu2204 container, which is supported by gcc, but not by clang, thus leading to a failure when compiling a C++ TCG plugin. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis Link: https://lore.kernel.org/qemu-devel/20260124182921.531562-8-pierrick.bouvier@linaro.org Signed-off-by: Pierrick Bouvier --- diff --git a/meson.build b/meson.build index 23252afc7d..ad8550d9e9 100644 --- a/meson.build +++ b/meson.build @@ -682,10 +682,7 @@ if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }' hardening_flags += '-fzero-call-used-regs=used-gpr' endif -qemu_common_flags += cc.get_supported_arguments(hardening_flags) - -add_global_arguments(qemu_common_flags, native: false, language: all_languages) -add_global_link_arguments(qemu_ldflags, native: false, language: all_languages) +qemu_common_flags += hardening_flags # Collect warning flags we want to set, sorted alphabetically warn_flags = [ @@ -744,15 +741,19 @@ if 'cpp' in all_languages qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags endif -add_project_arguments(qemu_cflags, native: false, language: 'c') -add_project_arguments(cc.get_supported_arguments(warn_flags), native: false, language: 'c') +add_project_arguments(cc.get_supported_arguments(qemu_common_flags + qemu_cflags + warn_flags), + native: false, language: 'c') +add_global_link_arguments(qemu_ldflags, native: false, language: all_languages) + if 'cpp' in all_languages - add_project_arguments(qemu_cxxflags, native: false, language: 'cpp') + add_project_arguments(cxx.get_supported_arguments(qemu_common_flags + qemu_cxxflags), + native: false, language: 'cpp') add_project_arguments(cxx.get_supported_arguments(warn_flags), native: false, language: 'cpp') endif if 'objc' in all_languages # Note sanitizer flags are not applied to Objective-C sources! - add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc') + add_project_arguments(objc.get_supported_arguments(qemu_common_flags + warn_flags), + native: false, language: 'objc') endif if host_os == 'linux' add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',