]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: enable more warnings when building efi binary
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Jun 2021 06:49:44 +0000 (15:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Jun 2021 06:49:44 +0000 (15:49 +0900)
meson.build
src/boot/efi/meson.build

index 65d0a0f6eaaf71e5cc98402716bc898651c483e0..696d84951c00508101b8553521180e8eb2bd0b05 100644 (file)
@@ -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')
index ad549fb65a972b8cca28ac6fa99782a0b48fd376..06b2fe5d81c603d72df478a6a09bff860edcbb88 100644 (file)
@@ -175,23 +175,27 @@ if have_gnu_efi
 endif
 
 if have_gnu_efi
-        compile_args = ['-Wall',
-                        '-Wextra',
-                        '-std=gnu99',
-                        '-nostdlib',
-                        '-fpic',
-                        '-fshort-wchar',
+        compile_args = cc.get_supported_arguments(
+                basic_disabled_warnings +
+                possible_common_cc_flags + [
                         '-ffreestanding',
-                        '-fno-strict-aliasing',
                         '-fno-stack-protector',
+                        '-fpic',
+                        '-fshort-wchar',
+                        '-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',