1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

meson: also check c_args to maybe add -Wno-maybe-uninitialized

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-04-29 14:35:20 +02:00 committed by Luca Boccassi
parent df8774263c
commit b528a62863

View 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