From bf7efeb16ff511779b2678bc07d0bf8bc4c48cb5 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Sat, 8 Sep 2018 13:55:09 -0700 Subject: [PATCH] build-sys: Use common gcc argument detection for negative warning flags. Starting with meson 0.46, it is able to detect these argument correctly. See this commit in meson codebase for more details: https://github.com/mesonbuild/meson/commit/695b8f3a0377d3e2ce78ba8716adc365b18edea1 We already carry a requirement for meson_version : '>= 0.46', so we can be sure our build system will include this commit. Tested by building systemd using a cloned meson synced to the 0.46.0 tag, confirmed the warnings were detected correctly in that case. The meson messages included this snippet: > Compiler for C supports arguments -Wno-unused-parameter -Wunused-parameter: YES > Compiler for C supports arguments -Wno-missing-field-initializers -Wmissing-field-initializers: YES > Compiler for C supports arguments -Wno-unused-result -Wunused-result: YES > Compiler for C supports arguments -Wno-format-signedness -Wformat-signedness: YES > Compiler for C supports arguments -Wno-error=nonnull -Werror=nonnull: YES > Compiler for C supports arguments -Wno-maybe-uninitialized -Wmaybe-uninitialized: YES --- meson.build | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/meson.build b/meson.build index 48a47f8103a..7ffe61246aa 100644 --- a/meson.build +++ b/meson.build @@ -321,6 +321,20 @@ possible_cc_flags = [ '-Werror=shift-overflow=2', '-Wdate-time', '-Wnested-externs', + + # negative arguments are correctly detected starting with meson 0.46. + '-Wno-unused-parameter', + '-Wno-missing-field-initializers', + '-Wno-unused-result', + '-Wno-format-signedness', + + # work-around for gcc 7.1 turning this on on its own. + '-Wno-error=nonnull', + + # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with + # optimizations enabled, producing essentially false positives. + '-Wno-maybe-uninitialized', + '-ffast-math', '-fno-common', '-fdiagnostics-show-option', @@ -364,23 +378,6 @@ endif add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c') add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c') -# "negative" arguments: gcc on purpose does not return an error for "-Wno-" -# arguments, just emits a warning. So test for the "positive" version instead. -foreach arg : ['unused-parameter', - 'missing-field-initializers', - 'unused-result', - 'format-signedness', - 'error=nonnull', # work-around for gcc 7.1 turning this on on its own - - # Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with - # optimizations enabled, producing essentially false positives. - 'maybe-uninitialized', - ] - if cc.has_argument('-W' + arg) - add_project_arguments('-Wno-' + arg, language : 'c') - endif -endforeach - if cc.compiles(''' #include #include -- 2.39.2