blob: e7b3e122380e37da2f98f28ff19e639309f346e6 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From cc38276a5d3926fd96e58366e15ba887d7d02ed0 Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: 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
Andrew Geissler517393d2023-01-13 08:55:19 -06005
Andrew Geissler7f40b712020-05-15 14:09:53 -0500617
7 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed,
819
9 Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if
10present
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011
12Use the passed in optflags when compiling as an RPM, and keep the
13default flags as close as possible to the current fedora flags, while
14still being generic.
15
16Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040017
18Upstream-Status: Pending
19
20update this patch to new version
21
22Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler517393d2023-01-13 08:55:19 -060023[OP: Rebase to 0.9.3]
24Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025---
Andrew Geissler517393d2023-01-13 08:55:19 -060026 Makefile.inc | 28 ++++++++++++++++++----------
27 1 file changed, 18 insertions(+), 10 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028
29diff --git a/Makefile.inc b/Makefile.inc
Andrew Geissler517393d2023-01-13 08:55:19 -060030index 57779fd8..34f2cc6d 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031--- a/Makefile.inc
32+++ b/Makefile.inc
Andrew Geissler517393d2023-01-13 08:55:19 -060033@@ -140,20 +140,28 @@ FORTIFY_OPT := $(shell \
34 echo "-D_FORTIFY_SOURCE=2"; \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035 fi)
36
37-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
Brad Bishop19323692019-04-05 15:28:33 -040038-ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)
Andrew Geissler517393d2023-01-13 08:55:19 -060039-WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,)
40-WFORMATOVERFLOW := $(call TEST_CC_OPTION,-Wformat-overflow=2,)
41-
42-OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4
43-WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \
44- -Werror=implicit-function-declaration -Werror=format-security \
45- $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046+ifndef RPM_OPT_FLAGS
Brad Bishop19323692019-04-05 15:28:33 -040047+ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
48+ OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \
49+ -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
50+ $(STACKPROT) --param=ssp-buffer-size=4 \
51+ -grecord-gcc-switches
52+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
53+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
54+ endif
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055+else
Brad Bishop19323692019-04-05 15:28:33 -040056+ OPTFLAGS = $(RPM_OPT_FLAGS)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057+endif
Brad Bishop19323692019-04-05 15:28:33 -040058+OPTFLAGS += -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \
59+ -Werror=implicit-function-declaration -Wno-sign-compare \
60+ -Wno-unused-parameter -Werror=cast-qual \
61+ -Werror=discarded-qualifiers
Andrew Geissler517393d2023-01-13 08:55:19 -060062+
63 CPPFLAGS := $(FORTIFY_OPT) \
64 -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(plugindir)\" -DRUN_DIR=\"${RUN}\" \
65 -DRUNTIME_DIR=\"$(runtimedir)\" \
66 -DCONFIG_DIR=\"$(configdir)\" -DEXTRAVERSION=\"$(EXTRAVERSION)\" -MMD -MP
67-CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe
68+CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) -pipe
69 BIN_CFLAGS = -fPIE -DPIE
70 LIB_CFLAGS = -fPIC
71 SHARED_FLAGS = -shared
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080072--
Andrew Geissler517393d2023-01-13 08:55:19 -0600732.38.1
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080074