Blame SOURCES/0150-build-Fix-Wall-and-O2-warnings.patch

2eb93d
From cbe337d6a0ee7d4f0ff9a5c19d14fb5e250df220 Mon Sep 17 00:00:00 2001
2eb93d
From: Dan Williams <dan.j.williams@intel.com>
2eb93d
Date: Wed, 9 Mar 2022 15:36:52 -0800
2eb93d
Subject: [PATCH 150/217] build: Fix '-Wall' and '-O2' warnings
2eb93d
2eb93d
Stop specifying '-Wall and '-O2' in cc_flags, and rely on the buildtype
2eb93d
and warning_level options. Fixup the '-D_FORTIFY_SOURCE=2' option to
2eb93d
optionally be enabled for optimizated builds rather then forcing -O2.
2eb93d
2eb93d
Link: https://github.com/pmem/ndctl/issues/195
2eb93d
Link: https://lore.kernel.org/r/164686901240.2874657.8473455139820858036.stgit@dwillia2-desk3.amr.corp.intel.com
2eb93d
Fixes: 4e5faa1726d2 ("build: Add meson build infrastructure")
2eb93d
Reported-by: Steve Scargall <steve.scargall@intel.com>
2eb93d
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 meson.build | 8 +++++---
2eb93d
 1 file changed, 5 insertions(+), 3 deletions(-)
2eb93d
2eb93d
diff --git a/meson.build b/meson.build
2eb93d
index 17ca65a..4dbb80d 100644
2eb93d
--- a/meson.build
2eb93d
+++ b/meson.build
2eb93d
@@ -57,7 +57,6 @@ sed -e s,@VERSION@,@0@,g
2eb93d
 '''.format(meson.project_version(), prefixdir, libdir, includedir).split()
2eb93d
 
2eb93d
 cc_flags = [
2eb93d
-  '-Wall',
2eb93d
   '-Wchar-subscripts',
2eb93d
   '-Wformat-security',
2eb93d
   '-Wmissing-declarations',
2eb93d
@@ -70,9 +69,12 @@ cc_flags = [
2eb93d
   '-Wmaybe-uninitialized',
2eb93d
   '-Wdeclaration-after-statement',
2eb93d
   '-Wunused-result',
2eb93d
-  '-D_FORTIFY_SOURCE=2',
2eb93d
-  '-O2',
2eb93d
 ]
2eb93d
+
2eb93d
+if get_option('optimization') != '0'
2eb93d
+  cc_flags += [ '-D_FORTIFY_SOURCE=2' ]
2eb93d
+endif
2eb93d
+
2eb93d
 cc = meson.get_compiler('c')
2eb93d
 add_project_arguments(cc.get_supported_arguments(cc_flags), language : 'c')
2eb93d
 
2eb93d
-- 
2eb93d
2.27.0
2eb93d