]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: also check c_args to maybe add -Wno-maybe-uninitialized
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 29 Apr 2022 12:35:20 +0000 (14:35 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 29 Apr 2022 19:03:11 +0000 (20:03 +0100)
People (and build systems) sometimes set flags through -Dc_args=… or $CFLAGS.
Let's catch this common case too. meson will set c_args from $CFLAGS, so we
only need to check the former.

meson.build

index 24568b550166cc8e28515276f6c864c05b98e243..582e33c9a73d103c57f021066999528ecacae4de 100644 (file)
@@ -361,12 +361,18 @@ possible_common_cc_flags = [
         '-Wno-string-plus-int',  # clang
 ]
 
+c_args = get_option('c_args')
+
 # Disable -Wmaybe-uninitialized 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'))
+                             cc.version().version_compare('<10') or
+                             '-Os' in c_args or
+                             '-O1' in c_args or
+                             '-O3' in c_args or
+                             '-Og' in c_args)
         possible_common_cc_flags += '-Wno-maybe-uninitialized'
 endif
 
@@ -3720,7 +3726,7 @@ test_cflags = ['-DTEST_CODE=1']
 # bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
 # use the variable unexpectedly. This triggers a lot of maybe-uninitialized
 # false positives when the combination of -O2 and -flto is used. Suppress them.
-if '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args')
+if '-O2' in c_args and '-flto=auto' in c_args
         test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
 endif