Stop specifying '-Wall and '-O2' in cc_flags, and rely on the buildtype
and warning_level options. Fixup the '-D_FORTIFY_SOURCE=2' option to
optionally be enabled for optimizated builds rather then forcing -O2.
Fixes: 4e5faa1726d2 ("build: Add meson build infrastructure")
Reported-by: Steve Scargall <[email protected]>
Link: https://github.com/pmem/ndctl/issues/195
Signed-off-by: Dan Williams <[email protected]>
---
meson.build | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/meson.build b/meson.build
index 5e97e1ce3068..a4149bb7b08c 100644
--- a/meson.build
+++ b/meson.build
@@ -57,7 +57,6 @@ sed -e s,@VERSION@,@0@,g
'''.format(meson.project_version(), prefixdir, libdir, includedir).split()
cc_flags = [
- '-Wall',
'-Wchar-subscripts',
'-Wformat-security',
'-Wmissing-declarations',
@@ -70,9 +69,12 @@ cc_flags = [
'-Wmaybe-uninitialized',
'-Wdeclaration-after-statement',
'-Wunused-result',
- '-D_FORTIFY_SOURCE=2',
- '-O2',
]
+
+if get_option('optimization') != '0'
+ cc_flags += [ '-D_FORTIFY_SOURCE=2' ]
+endif
+
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments(cc_flags), language : 'c')