From 65267363978dbb298eb4ba9b628d028c969fa616 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 2 Jun 2021 15:49:44 +0900 Subject: [PATCH] meson: enable more warnings when building efi binary --- meson.build | 19 +++++++++++-------- src/boot/efi/meson.build | 32 ++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index 65d0a0f6eaa..696d84951c0 100644 --- a/meson.build +++ b/meson.build @@ -325,7 +325,7 @@ basic_disabled_warnings = [ '-Wno-format-signedness', ] -possible_cc_flags = [ +possible_common_cc_flags = [ '-Werror=undef', '-Wlogical-op', '-Wmissing-include-dirs', @@ -334,9 +334,7 @@ possible_cc_flags = [ '-Winit-self', '-Wfloat-equal', '-Wsuggest-attribute=noreturn', - '-Werror=missing-prototypes', '-Werror=implicit-function-declaration', - '-Werror=missing-declarations', '-Werror=return-type', '-Werror=incompatible-pointer-types', '-Werror=format=2', @@ -363,8 +361,6 @@ possible_cc_flags = [ '-fdiagnostics-show-option', '-fno-strict-aliasing', '-fvisibility=hidden', - '-fstack-protector', - '-fstack-protector-strong', '--param=ssp-buffer-size=4', ] @@ -374,7 +370,7 @@ possible_cc_flags = [ # busywork. See https://github.com/systemd/systemd/pull/19226. if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or cc.version().version_compare('<10')) - possible_cc_flags += '-Wno-maybe-uninitialized' + possible_common_cc_flags += '-Wno-maybe-uninitialized' endif # --as-needed and --no-undefined are provided by meson by default, @@ -386,14 +382,14 @@ possible_link_flags = [ ] if cc.get_id() == 'clang' - possible_cc_flags += [ + possible_common_cc_flags += [ '-Wno-typedef-redefinition', '-Wno-gnu-variable-sized-type-not-at-end', ] endif if get_option('buildtype') != 'debug' - possible_cc_flags += [ + possible_common_cc_flags += [ '-ffunction-sections', '-fdata-sections', ] @@ -401,6 +397,13 @@ if get_option('buildtype') != 'debug' possible_link_flags += '-Wl,--gc-sections' endif +possible_cc_flags = possible_common_cc_flags + [ + '-Werror=missing-declarations', + '-Werror=missing-prototypes', + '-fstack-protector', + '-fstack-protector-strong', +] + add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), 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') diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index ad549fb65a9..06b2fe5d81c 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -175,23 +175,27 @@ if have_gnu_efi endif if have_gnu_efi - compile_args = ['-Wall', - '-Wextra', - '-std=gnu99', - '-nostdlib', + compile_args = cc.get_supported_arguments( + basic_disabled_warnings + + possible_common_cc_flags + [ + '-ffreestanding', + '-fno-stack-protector', '-fpic', '-fshort-wchar', - '-ffreestanding', - '-fno-strict-aliasing', - '-fno-stack-protector', + '-Wall', + '-Wextra', '-Wsign-compare', - '-Wno-missing-field-initializers', - '-isystem', efi_incdir, - '-isystem', join_paths(efi_incdir, gnu_efi_path_arch), - '-I', fundamental_path, - '-DSD_BOOT', - '-include', efi_config_h, - '-include', version_h] + ] + ) + [ + '-nostdlib', + '-std=gnu99', + '-isystem', efi_incdir, + '-isystem', join_paths(efi_incdir, gnu_efi_path_arch), + '-I', fundamental_path, + '-DSD_BOOT', + '-include', efi_config_h, + '-include', version_h, + ] if efi_arch == 'x86_64' compile_args += ['-mno-red-zone', '-mno-sse',