build: tweak build flags

Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2022-06-09 18:07:35 +02:00 committed by Christian Brauner (Microsoft)
parent cb3178a604
commit abc5e6bb94
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -155,6 +155,14 @@ endif
dummy_config_data = configuration_data()
dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
# Those generate many false positives, and we do not want to change the code to
# avoid them.
basic_disabled_warnings = [
'-Wno-format-signedness',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
]
# Build flags.
possible_cc_flags = [
'-Wvla',
@ -193,7 +201,6 @@ possible_cc_flags = [
'-Wreturn-local-addr',
'-fsanitize=cfi',
'-Wstringop-overflow',
'-Wno-missing-field-initializers',
]
possible_link_flags = [
@ -201,14 +208,27 @@ possible_link_flags = [
'-Wl,-z,relro',
'-Wl,-z,now',
'-Wl,-fuse-ld=gold',
'-fstack-protector',
]
if sanitize == 'none'
possible_link_flags += '-Wl,--warn-common'
endif
if cc.get_id() == 'clang'
possible_cc_flags += [
'-Wno-typedef-redefinition',
'-Wno-gnu-variable-sized-type-not-at-end',
]
endif
if meson.version().version_compare('>=0.46')
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language: 'c')
else
add_project_link_arguments(possible_link_flags, language: 'c')
endif
add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language: 'c')
# Feature detection