anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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