mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-08-30 05:50:12 +03:00
Merge pull request #13989 from keszybz/meson-warning
Adjust compiler option management to avoid warnings from meson
This commit is contained in:
42
meson.build
42
meson.build
@ -8,6 +8,7 @@ project('systemd', 'c',
|
|||||||
'prefix=/usr',
|
'prefix=/usr',
|
||||||
'sysconfdir=/etc',
|
'sysconfdir=/etc',
|
||||||
'localstatedir=/var',
|
'localstatedir=/var',
|
||||||
|
'warning_level=2',
|
||||||
],
|
],
|
||||||
meson_version : '>= 0.46',
|
meson_version : '>= 0.46',
|
||||||
)
|
)
|
||||||
@ -302,7 +303,8 @@ install_tests = get_option('install-tests')
|
|||||||
|
|
||||||
if add_languages('cpp', required : fuzzer_build)
|
if add_languages('cpp', required : fuzzer_build)
|
||||||
# Used only for tests
|
# Used only for tests
|
||||||
cxx_cmd = ' '.join(meson.get_compiler('cpp').cmd_array())
|
cxx = meson.get_compiler('cpp')
|
||||||
|
cxx_cmd = ' '.join(cxx.cmd_array())
|
||||||
else
|
else
|
||||||
cxx_cmd = ''
|
cxx_cmd = ''
|
||||||
endif
|
endif
|
||||||
@ -322,8 +324,25 @@ elif want_fuzzbuzz
|
|||||||
fuzzing_engine = meson.get_compiler('cpp').find_library(get_option('fuzzbuzz-engine'), dirs: get_option('fuzzbuzz-engine-dir'))
|
fuzzing_engine = meson.get_compiler('cpp').find_library(get_option('fuzzbuzz-engine'), dirs: get_option('fuzzbuzz-engine-dir'))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Those generate many false positives, and we do not want to change the code to
|
||||||
|
# avoid them.
|
||||||
|
basic_disabled_warnings = [
|
||||||
|
'-Wno-unused-parameter',
|
||||||
|
'-Wno-missing-field-initializers',
|
||||||
|
'-Wno-unused-result',
|
||||||
|
'-Wno-format-signedness',
|
||||||
|
]
|
||||||
|
if get_option('b_ndebug') == 'true'
|
||||||
|
# With asserts disabled with get a bunch of warnings about variables which
|
||||||
|
# are used only in the asserts. This is not useful at all, so let's just silence
|
||||||
|
# those warnings.
|
||||||
|
basic_disabled_warnings += [
|
||||||
|
'-Wno-unused-variable',
|
||||||
|
'-Wno-unused-but-set-variable',
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
possible_cc_flags = [
|
possible_cc_flags = [
|
||||||
'-Wextra',
|
|
||||||
'-Werror=undef',
|
'-Werror=undef',
|
||||||
'-Wlogical-op',
|
'-Wlogical-op',
|
||||||
'-Wmissing-include-dirs',
|
'-Wmissing-include-dirs',
|
||||||
@ -353,10 +372,6 @@ possible_cc_flags = [
|
|||||||
'-Wnested-externs',
|
'-Wnested-externs',
|
||||||
|
|
||||||
# negative arguments are correctly detected starting with meson 0.46.
|
# negative arguments are correctly detected starting with meson 0.46.
|
||||||
'-Wno-unused-parameter',
|
|
||||||
'-Wno-missing-field-initializers',
|
|
||||||
'-Wno-unused-result',
|
|
||||||
'-Wno-format-signedness',
|
|
||||||
'-Wno-error=#warnings', # clang
|
'-Wno-error=#warnings', # clang
|
||||||
'-Wno-string-plus-int', # clang
|
'-Wno-string-plus-int', # clang
|
||||||
|
|
||||||
@ -401,16 +416,7 @@ if get_option('buildtype') != 'debug'
|
|||||||
possible_link_flags += '-Wl,--gc-sections'
|
possible_link_flags += '-Wl,--gc-sections'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('b_ndebug') == 'true'
|
add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
|
||||||
# With asserts disabled with get a bunch of warnings about variables which
|
|
||||||
# are used only in the asserts. This is not useful at all, so let's just silence
|
|
||||||
# those warnings.
|
|
||||||
possible_cc_flags += [
|
|
||||||
'-Wno-unused-variable',
|
|
||||||
'-Wno-unused-but-set-variable',
|
|
||||||
]
|
|
||||||
endif
|
|
||||||
|
|
||||||
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
|
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')
|
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
|
||||||
|
|
||||||
@ -427,6 +433,10 @@ if cc.compiles('''
|
|||||||
add_project_arguments('-Werror=shadow', language : 'c')
|
add_project_arguments('-Werror=shadow', language : 'c')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if cxx_cmd != ''
|
||||||
|
add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
|
||||||
|
endif
|
||||||
|
|
||||||
cpp = ' '.join(cc.cmd_array()) + ' -E'
|
cpp = ' '.join(cc.cmd_array()) + ' -E'
|
||||||
|
|
||||||
has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
|
has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
|
||||||
|
@ -11,12 +11,11 @@ test_hashmap_ordered_c = custom_target(
|
|||||||
|
|
||||||
test_include_dir = include_directories('.')
|
test_include_dir = include_directories('.')
|
||||||
|
|
||||||
path = run_command('sh', ['-c', 'echo "$PATH"']).stdout()
|
path = run_command('sh', ['-c', 'echo "$PATH"']).stdout().strip()
|
||||||
test_env = environment()
|
test_env = environment()
|
||||||
test_env.set('SYSTEMD_KBD_MODEL_MAP', kbd_model_map)
|
test_env.set('SYSTEMD_KBD_MODEL_MAP', kbd_model_map)
|
||||||
test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
|
test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
|
||||||
test_env.set('PATH', path)
|
test_env.set('PATH', '@0@:@1@'.format(meson.build_root(), path))
|
||||||
test_env.prepend('PATH', meson.build_root())
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user