[calls/wip/compiler-warnings: 12/12] meson: Use stricter compilation warnings and errors




commit 20b73fee04055e95fcfbfa8422f24d8acbd0e450
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Wed Jun 2 20:51:47 2021 +0200

    meson: Use stricter compilation warnings and errors
    
    All the previous commits make sure we don't fail building with these flags.

 meson.build | 53 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/meson.build b/meson.build
index c79cbe7e..6a1f6883 100644
--- a/meson.build
+++ b/meson.build
@@ -67,10 +67,54 @@ configure_file(
   output: 'run',
   configuration: run_data)
 
-add_project_arguments([
- '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_58',
- '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_64',
-], language: 'c')
+cc = meson.get_compiler('c')
+
+global_c_args = []
+test_c_args = [
+  '-Wcast-align',
+  '-Wdate-time',
+  '-Wdeclaration-after-statement',
+  ['-Werror=format-security', '-Werror=format=2'],
+  '-Wendif-labels',
+  '-Werror=incompatible-pointer-types',
+  '-Werror=missing-declarations',
+  '-Werror=overflow',
+  '-Werror=return-type',
+  '-Werror=shift-count-overflow',
+  '-Werror=shift-overflow=2',
+  '-Wfloat-equal',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Winit-self',
+  '-Wmaybe-uninitialized',
+  '-Wmissing-include-dirs',
+  '-Wmissing-noreturn',
+  '-Wnested-externs',
+  '-Wold-style-definition',
+  '-Wshadow',
+  '-Wstrict-prototypes',
+  '-Wswitch-default',
+  '-Wno-switch-enum',
+  '-Wtype-limits',
+  '-Wunused-function',
+  '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_58',
+ '  -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_66',
+]
+
+if get_option('buildtype') != 'plain'
+  test_c_args += '-fstack-protector-strong'
+endif
+
+foreach arg: test_c_args
+  if cc.has_multi_arguments(arg)
+    global_c_args += arg
+  endif
+endforeach
+
+add_project_arguments(
+  global_c_args,
+  language: 'c'
+)
 
 subdir('po')
 subdir('src')
@@ -78,3 +122,4 @@ subdir('plugins')
 subdir('doc')
 subdir('data')
 subdir('tests')
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]