Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 436f7594485e35523269e662c4b5dc3a2c10ff9b Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Mon, 26 Nov 2018 09:19:17 +0800 |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 4 | Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep |
| 5 | 17 |
| 6 | 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed, |
| 7 | 19 |
| 8 | Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if |
| 9 | present |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | |
| 11 | Use the passed in optflags when compiling as an RPM, and keep the |
| 12 | default flags as close as possible to the current fedora flags, while |
| 13 | still being generic. |
| 14 | |
| 15 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 16 | |
| 17 | Upstream-Status: Pending |
| 18 | |
| 19 | update this patch to new version |
| 20 | |
| 21 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 22 | --- |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 23 | Makefile.inc | 24 ++++++++++++++++-------- |
| 24 | 1 file changed, 16 insertions(+), 8 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 25 | |
| 26 | diff --git a/Makefile.inc b/Makefile.inc |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 27 | index 42dbb5bf..55a06c60 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | --- a/Makefile.inc |
| 29 | +++ b/Makefile.inc |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 30 | @@ -89,15 +89,23 @@ TEST_CC_OPTION = $(shell \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | echo "$(2)"; \ |
| 32 | fi) |
| 33 | |
| 34 | -STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | -ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 36 | -WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 37 | +ifndef RPM_OPT_FLAGS |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | +else |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 47 | + OPTFLAGS = $(RPM_OPT_FLAGS) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | +endif |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 49 | +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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 53 | |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 54 | -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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 60 | CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ |
| 61 | -MMD -MP $(CFLAGS) |
| 62 | -- |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 63 | 2.17.1 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 64 | |