blob: 17542fd4fdcd8f7b22f17ab44edc2ba517a9d1fb [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 436f7594485e35523269e662c4b5dc3a2c10ff9b Mon Sep 17 00:00:00 2001
2From: Changqing Li <changqing.li@windriver.com>
3Date: Mon, 26 Nov 2018 09:19:17 +0800
Andrew Geissler7f40b712020-05-15 14:09:53 -05004Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep
517
6 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed,
719
8 Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if
9present
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010
11Use the passed in optflags when compiling as an RPM, and keep the
12default flags as close as possible to the current fedora flags, while
13still being generic.
14
15Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040016
17Upstream-Status: Pending
18
19update this patch to new version
20
21Signed-off-by: Changqing Li <changqing.li@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022---
Andrew Geissler7f40b712020-05-15 14:09:53 -050023 Makefile.inc | 24 ++++++++++++++++--------
24 1 file changed, 16 insertions(+), 8 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025
26diff --git a/Makefile.inc b/Makefile.inc
Andrew Geissler7f40b712020-05-15 14:09:53 -050027index 42dbb5bf..55a06c60 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028--- a/Makefile.inc
29+++ b/Makefile.inc
Andrew Geissler7f40b712020-05-15 14:09:53 -050030@@ -89,15 +89,23 @@ TEST_CC_OPTION = $(shell \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031 echo "$(2)"; \
32 fi)
33
34-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
Brad Bishop19323692019-04-05 15:28:33 -040035-ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)
Andrew Geissler7f40b712020-05-15 14:09:53 -050036-WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080037+ifndef RPM_OPT_FLAGS
Brad Bishop19323692019-04-05 15:28:33 -040038+ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
39+ OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \
40+ -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
41+ $(STACKPROT) --param=ssp-buffer-size=4 \
42+ -grecord-gcc-switches
43+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
44+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
45+ endif
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046+else
Brad Bishop19323692019-04-05 15:28:33 -040047+ OPTFLAGS = $(RPM_OPT_FLAGS)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048+endif
Brad Bishop19323692019-04-05 15:28:33 -040049+OPTFLAGS += -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \
50+ -Werror=implicit-function-declaration -Wno-sign-compare \
51+ -Wno-unused-parameter -Werror=cast-qual \
52+ -Werror=discarded-qualifiers
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053
Andrew Geissler7f40b712020-05-15 14:09:53 -050054-OPTFLAGS = -O2 -g -pipe -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \
55- -Werror=implicit-function-declaration -Werror=format-security \
56- $(WNOCLOBBERED) \
57- -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
58- $(STACKPROT) --param=ssp-buffer-size=4
59 CPPFLAGS := -Wp,-D_FORTIFY_SOURCE=2
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080060 CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
61 -MMD -MP $(CFLAGS)
62--
Andrew Geissler7f40b712020-05-15 14:09:53 -0500632.17.1
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080064