diff mbox series

[ndctl] build: Fix '-Wall' and '-O2' warnings

Message ID 164686901240.2874657.8473455139820858036.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit cbe337d6a0ee7d4f0ff9a5c19d14fb5e250df220
Headers show
Series [ndctl] build: Fix '-Wall' and '-O2' warnings | expand

Commit Message

Dan Williams March 9, 2022, 11:36 p.m. UTC
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 <steve.scargall@intel.com>
Link: https://github.com/pmem/ndctl/issues/195
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 meson.build |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

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')