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
148
meson.build
148
meson.build
|
@ -11,7 +11,7 @@ project('systemd', 'c',
|
||||||
'sysconfdir=/etc',
|
'sysconfdir=/etc',
|
||||||
'localstatedir=/var',
|
'localstatedir=/var',
|
||||||
],
|
],
|
||||||
meson_version : '>= 0.41',
|
meson_version : '>= 0.43',
|
||||||
)
|
)
|
||||||
|
|
||||||
libsystemd_version = '0.22.0'
|
libsystemd_version = '0.22.0'
|
||||||
|
@ -291,55 +291,76 @@ if want_ossfuzz
|
||||||
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach arg : ['-Wextra',
|
possible_cc_flags = [
|
||||||
'-Werror=undef',
|
'-Wextra',
|
||||||
'-Wlogical-op',
|
'-Werror=undef',
|
||||||
'-Wmissing-include-dirs',
|
'-Wlogical-op',
|
||||||
'-Wold-style-definition',
|
'-Wmissing-include-dirs',
|
||||||
'-Wpointer-arith',
|
'-Wold-style-definition',
|
||||||
'-Winit-self',
|
'-Wpointer-arith',
|
||||||
'-Wdeclaration-after-statement',
|
'-Winit-self',
|
||||||
'-Wfloat-equal',
|
'-Wdeclaration-after-statement',
|
||||||
'-Wsuggest-attribute=noreturn',
|
'-Wfloat-equal',
|
||||||
'-Werror=missing-prototypes',
|
'-Wsuggest-attribute=noreturn',
|
||||||
'-Werror=implicit-function-declaration',
|
'-Werror=missing-prototypes',
|
||||||
'-Werror=missing-declarations',
|
'-Werror=implicit-function-declaration',
|
||||||
'-Werror=return-type',
|
'-Werror=missing-declarations',
|
||||||
'-Werror=incompatible-pointer-types',
|
'-Werror=return-type',
|
||||||
'-Werror=format=2',
|
'-Werror=incompatible-pointer-types',
|
||||||
'-Wstrict-prototypes',
|
'-Werror=format=2',
|
||||||
'-Wredundant-decls',
|
'-Wstrict-prototypes',
|
||||||
'-Wmissing-noreturn',
|
'-Wredundant-decls',
|
||||||
'-Wimplicit-fallthrough=5',
|
'-Wmissing-noreturn',
|
||||||
'-Wshadow',
|
'-Wimplicit-fallthrough=5',
|
||||||
'-Wendif-labels',
|
'-Wshadow',
|
||||||
'-Wstrict-aliasing=2',
|
'-Wendif-labels',
|
||||||
'-Wwrite-strings',
|
'-Wstrict-aliasing=2',
|
||||||
'-Werror=overflow',
|
'-Wwrite-strings',
|
||||||
'-Wdate-time',
|
'-Werror=overflow',
|
||||||
'-Wnested-externs',
|
'-Wdate-time',
|
||||||
'-ffast-math',
|
'-Wnested-externs',
|
||||||
'-fno-common',
|
'-ffast-math',
|
||||||
'-fdiagnostics-show-option',
|
'-fno-common',
|
||||||
'-fno-strict-aliasing',
|
'-fdiagnostics-show-option',
|
||||||
'-fvisibility=hidden',
|
'-fno-strict-aliasing',
|
||||||
'-fstack-protector',
|
'-fvisibility=hidden',
|
||||||
'-fstack-protector-strong',
|
'-fstack-protector',
|
||||||
'--param=ssp-buffer-size=4',
|
'-fstack-protector-strong',
|
||||||
]
|
'--param=ssp-buffer-size=4',
|
||||||
if cc.has_argument(arg)
|
]
|
||||||
add_project_arguments(arg, language : 'c')
|
|
||||||
endif
|
# --as-needed and --no-undefined are provided by meson by default,
|
||||||
endforeach
|
# 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
|
# the oss-fuzz fuzzers are not built with -fPIE, so don't
|
||||||
# enable it when we are linking against them
|
# enable it when we are linking against them
|
||||||
if not fuzzer_build
|
if not fuzzer_build
|
||||||
if cc.has_argument('-fPIE')
|
possible_cc_flags += '-fPIE'
|
||||||
add_project_arguments('-fPIE', language : 'c')
|
possible_link_flags += '-pie'
|
||||||
endif
|
|
||||||
endif
|
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-"
|
# "negative" arguments: gcc on purpose does not return an error for "-Wno-"
|
||||||
# arguments, just emits a warnings. So test for the "positive" version instead.
|
# arguments, just emits a warnings. So test for the "positive" version instead.
|
||||||
foreach arg : ['unused-parameter',
|
foreach arg : ['unused-parameter',
|
||||||
|
@ -366,53 +387,18 @@ if cc.compiles('''
|
||||||
add_project_arguments('-Werror=shadow', language : 'c')
|
add_project_arguments('-Werror=shadow', language : 'c')
|
||||||
endif
|
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')
|
link_test_c = files('tools/meson-link-test.c')
|
||||||
|
|
||||||
# --as-needed and --no-undefined are provided by meson by default,
|
foreach arg : possible_link_flags
|
||||||
# run mesonconf to see what is enabled
|
|
||||||
foreach arg : ['-Wl,-z,relro',
|
|
||||||
'-Wl,-z,now',
|
|
||||||
'-pie',
|
|
||||||
]
|
|
||||||
|
|
||||||
have = run_command(check_compilation_sh,
|
have = run_command(check_compilation_sh,
|
||||||
cc.cmd_array(), '-x', 'c', arg,
|
cc.cmd_array(), '-x', 'c', arg,
|
||||||
'-include', link_test_c).returncode() == 0
|
'-include', link_test_c).returncode() == 0
|
||||||
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
|
message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
|
||||||
if have and (arg != '-pie' or not fuzzer_build)
|
if have
|
||||||
add_project_link_arguments(arg, language : 'c')
|
add_project_link_arguments(arg, language : 'c')
|
||||||
endif
|
endif
|
||||||
endforeach
|
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']
|
|
||||||
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
|
|
||||||
add_project_link_arguments(arg, language : 'c')
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
endif
|
|
||||||
|
|
||||||
cpp = ' '.join(cc.cmd_array()) + ' -E'
|
cpp = ' '.join(cc.cmd_array()) + ' -E'
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
Loading…
Reference in New Issue