mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +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:
parent
df8774263c
commit
b528a62863
10
meson.build
10
meson.build
@ -361,12 +361,18 @@ possible_common_cc_flags = [
|
|||||||
'-Wno-string-plus-int', # clang
|
'-Wno-string-plus-int', # clang
|
||||||
]
|
]
|
||||||
|
|
||||||
|
c_args = get_option('c_args')
|
||||||
|
|
||||||
# Disable -Wmaybe-uninitialized when compiling with -Os/-O1/-O3/etc. There are
|
# 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
|
# 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
|
# and -O2; this should be enough to catch most important cases without too much
|
||||||
# busywork. See https://github.com/systemd/systemd/pull/19226.
|
# busywork. See https://github.com/systemd/systemd/pull/19226.
|
||||||
if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
|
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'
|
possible_common_cc_flags += '-Wno-maybe-uninitialized'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -3720,7 +3726,7 @@ test_cflags = ['-DTEST_CODE=1']
|
|||||||
# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
|
# bunch of _cleanup_ variables in tests, to ensure valgrind is triggered if we
|
||||||
# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
|
# use the variable unexpectedly. This triggers a lot of maybe-uninitialized
|
||||||
# false positives when the combination of -O2 and -flto is used. Suppress them.
|
# 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')
|
test_cflags += cc.first_supported_argument('-Wno-maybe-uninitialized')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user