mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
meson: use get_supported_arguments()
This bumps the required minimum version of meson to 0.43, as `get_supported_arguments()` is supported since meson-0.43.
This commit is contained in:
parent
7cfcb25236
commit
30a4ddff7f
80
meson.build
80
meson.build
@ -11,7 +11,7 @@ project('systemd', 'c',
|
||||
'sysconfdir=/etc',
|
||||
'localstatedir=/var',
|
||||
],
|
||||
meson_version : '>= 0.41',
|
||||
meson_version : '>= 0.43',
|
||||
)
|
||||
|
||||
libsystemd_version = '0.22.0'
|
||||
@ -291,7 +291,8 @@ if want_ossfuzz
|
||||
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
||||
endif
|
||||
|
||||
foreach arg : ['-Wextra',
|
||||
possible_cc_flags = [
|
||||
'-Wextra',
|
||||
'-Werror=undef',
|
||||
'-Wlogical-op',
|
||||
'-Wmissing-include-dirs',
|
||||
@ -326,20 +327,40 @@ foreach arg : ['-Wextra',
|
||||
'-fstack-protector',
|
||||
'-fstack-protector-strong',
|
||||
'--param=ssp-buffer-size=4',
|
||||
]
|
||||
if cc.has_argument(arg)
|
||||
add_project_arguments(arg, language : 'c')
|
||||
endif
|
||||
endforeach
|
||||
]
|
||||
|
||||
# --as-needed and --no-undefined are provided by meson by default,
|
||||
# run mesonconf to see what is enabled
|
||||
possible_link_flags = [
|
||||
'-Wl,-z,relro',
|
||||
'-Wl,-z,now',
|
||||
]
|
||||
|
||||
# the oss-fuzz fuzzers are not built with -fPIE, so don't
|
||||
# enable it when we are linking against them
|
||||
if not fuzzer_build
|
||||
if cc.has_argument('-fPIE')
|
||||
add_project_arguments('-fPIE', language : 'c')
|
||||
endif
|
||||
possible_cc_flags += '-fPIE'
|
||||
possible_link_flags += '-pie'
|
||||
endif
|
||||
|
||||
if cc.get_id() == 'clang'
|
||||
possible_cc_flags += [
|
||||
'-Wno-typedef-redefinition',
|
||||
'-Wno-gnu-variable-sized-type-not-at-end',
|
||||
]
|
||||
endif
|
||||
|
||||
if get_option('buildtype') != 'debug'
|
||||
possible_cc_flags += [
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
]
|
||||
|
||||
possible_link_flags += '-Wl,--gc-sections'
|
||||
endif
|
||||
|
||||
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
|
||||
|
||||
# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
|
||||
# arguments, just emits a warnings. So test for the "positive" version instead.
|
||||
foreach arg : ['unused-parameter',
|
||||
@ -366,43 +387,9 @@ if cc.compiles('''
|
||||
add_project_arguments('-Werror=shadow', language : 'c')
|
||||
endif
|
||||
|
||||
if cc.get_id() == 'clang'
|
||||
foreach arg : ['-Wno-typedef-redefinition',
|
||||
'-Wno-gnu-variable-sized-type-not-at-end',
|
||||
]
|
||||
if cc.has_argument(arg)
|
||||
add_project_arguments(arg, language : 'c')
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
|
||||
link_test_c = files('tools/meson-link-test.c')
|
||||
|
||||
# --as-needed and --no-undefined are provided by meson by default,
|
||||
# run mesonconf to see what is enabled
|
||||
foreach arg : ['-Wl,-z,relro',
|
||||
'-Wl,-z,now',
|
||||
'-pie',
|
||||
]
|
||||
|
||||
have = run_command(check_compilation_sh,
|
||||
cc.cmd_array(), '-x', 'c', arg,
|
||||
'-include', link_test_c).returncode() == 0
|
||||
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
|
||||
if have and (arg != '-pie' or not fuzzer_build)
|
||||
add_project_link_arguments(arg, language : 'c')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if get_option('buildtype') != 'debug'
|
||||
foreach arg : ['-ffunction-sections',
|
||||
'-fdata-sections']
|
||||
if cc.has_argument(arg)
|
||||
add_project_arguments(arg, language : 'c')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
foreach arg : ['-Wl,--gc-sections']
|
||||
foreach arg : possible_link_flags
|
||||
have = run_command(check_compilation_sh,
|
||||
cc.cmd_array(), '-x', 'c', arg,
|
||||
'-include', link_test_c).returncode() == 0
|
||||
@ -410,8 +397,7 @@ if get_option('buildtype') != 'debug'
|
||||
if have
|
||||
add_project_link_arguments(arg, language : 'c')
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
endforeach
|
||||
|
||||
cpp = ' '.join(cc.cmd_array()) + ' -E'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user