Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | From cc38276a5d3926fd96e58366e15ba887d7d02ed0 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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 |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 5 | |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 6 | 17 |
| 7 | 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed, |
| 8 | 19 |
| 9 | Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if |
| 10 | present |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 11 | |
| 12 | Use the passed in optflags when compiling as an RPM, and keep the |
| 13 | default flags as close as possible to the current fedora flags, while |
| 14 | still being generic. |
| 15 | |
| 16 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 17 | |
| 18 | Upstream-Status: Pending |
| 19 | |
| 20 | update this patch to new version |
| 21 | |
| 22 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 23 | [OP: Rebase to 0.9.3] |
| 24 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 25 | --- |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 26 | Makefile.inc | 28 ++++++++++++++++++---------- |
| 27 | 1 file changed, 18 insertions(+), 10 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | |
| 29 | diff --git a/Makefile.inc b/Makefile.inc |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 30 | index 57779fd8..34f2cc6d 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | --- a/Makefile.inc |
| 32 | +++ b/Makefile.inc |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 33 | @@ -140,20 +140,28 @@ FORTIFY_OPT := $(shell \ |
| 34 | echo "-D_FORTIFY_SOURCE=2"; \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | fi) |
| 36 | |
| 37 | -STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | -ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 39 | -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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | +ifndef RPM_OPT_FLAGS |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 47 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | +else |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 56 | + OPTFLAGS = $(RPM_OPT_FLAGS) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | +endif |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | +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 Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 62 | + |
| 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 72 | -- |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 73 | 2.38.1 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 74 | |