anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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