From: Zbigniew Jędrzejewski-Szmek Date: Wed, 31 Mar 2021 15:05:49 +0000 (+0200) Subject: meson: re-enable -Wmaybe-uninitialized on -O[02] with recent gcc versions X-Git-Tag: v249-rc1~456^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=68c98a411d67ea64bb356ca02e01e8ec7defbef9;p=thirdparty%2Fsystemd.git meson: re-enable -Wmaybe-uninitialized on -O[02] with recent gcc versions The warning was disabled in 8794164fed5f0142c34358613f92f4f761af4edd to avoid false positives. But it is useful in finding errors, even if it sometimes results in untrue warnings (c.f. 77fac974fe, da46a1bc3c). After #19168, #19169, and #19175, there are no warnings with -Dbuildtype=debug-optimized/-O2 and gcc-11.0.1-0.3.fc34.x86_64. Warnings are reenabled for -O[23] -O0 is good for development, and -O2 is the default optimization level for Fedora package builds. -Os, -O3, -O1, and -Og still generate some warnings. In fact, with -Os the number of warnings seems completely hopeless. Dozens and dozens. --- diff --git a/meson.build b/meson.build index 2d44e7948dd..a8976c20374 100644 --- a/meson.build +++ b/meson.build @@ -395,10 +395,6 @@ possible_cc_flags = [ '-Wno-error=#warnings', # clang '-Wno-string-plus-int', # clang - # 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', @@ -409,6 +405,15 @@ possible_cc_flags = [ '--param=ssp-buffer-size=4', ] +# Disable -Wmaybe-unitialized when compiling with -Os/-O1/-O3/etc. There are +# too many false positives with gcc >= 8. Effectively, we only test with -O0 +# and -O2; this should be enough to catch most important cases without too much +# busywork. See https://github.com/systemd/systemd/pull/19226. +if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or + cc.version().version_compare('<10')) + possible_cc_flags += '-Wno-maybe-uninitialized' +endif + # --as-needed and --no-undefined are provided by meson by default, # run mesonconf to see what is enabled possible_link_flags = [