Patchwork [11/16] Enable -fstack-protector=* when requested by configure.

login
register
mail settings
Submitter Nix
Date Feb. 28, 2016, 4:41 p.m.
Message ID <1456677695-29778-12-git-send-email-nix@esperi.org.uk>
Download mbox | patch
Permalink /patch/11128/
State New
Headers show

Comments

Nix - Feb. 28, 2016, 4:41 p.m.
From: Nick Alcock <nick.alcock@oracle.com>

This finally turns on all the machinery added in previous commits.

v3: Wrap long lines.
---
 Makeconfig | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Andreas Schwab - Feb. 28, 2016, 8:25 p.m.
Nix <nix@esperi.org.uk> writes:

> +# We might want to compile with some stack-protection flag.
> +ifneq ($(stack-protector),)
> ++stack-protector=$(stack-protector)
> +endif

Why do you need that indirection?

Andreas.
Nix - Feb. 29, 2016, 10:28 a.m.
On 28 Feb 2016, Andreas Schwab outgrape:

> Nix <nix@esperi.org.uk> writes:
>
>> +# We might want to compile with some stack-protection flag.
>> +ifneq ($(stack-protector),)
>> ++stack-protector=$(stack-protector)
>> +endif
>
> Why do you need that indirection?

For consistency: almost everything else added to +cflags has a
similarly-prepended name (even when it's always set to a literal
constant: e.g +merge-constants and +math-flags).

I'm happy to drop it if people think it's redundant: it's not like
$(+stack-protector) is used anywhere else.

Patch

diff --git a/Makeconfig b/Makeconfig
index 87a22e8..efcfdad 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -762,6 +762,11 @@  endif
 # disable any optimization that assume default rounding mode.
 +math-flags = -frounding-math
 
+# We might want to compile with some stack-protection flag.
+ifneq ($(stack-protector),)
++stack-protector=$(stack-protector)
+endif
+
 # This is the program that generates makefile dependencies from C source files.
 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
 # targets for headers so that removed headers don't break the build.
@@ -821,7 +826,8 @@  ifeq	"$(strip $(+cflags))" ""
 +cflags	:= $(default_cflags)
 endif	# $(+cflags) == ""
 
-+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
++cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
+	   $(+stack-protector)
 +gcc-nowarn := -w
 
 # Don't duplicate options if we inherited variables from the parent.