pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/compiler mk: Fix SSP detection when using pkgsrc GCC.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/76e8b8200102
branches:  trunk
changeset: 369701:76e8b8200102
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Tue Oct 03 09:38:16 2017 +0000

description:
mk: Fix SSP detection when using pkgsrc GCC.

We can't rely on _GCC_VERSION as an accurate indicator of the GCC version,
as when using a pkgsrc GCC it will be set to 0 until the pkgsrc GCC is
available and we can detect its version.  Instead, move the logic later to
after CC_VERSION is set and use that instead.

diffstat:

 mk/compiler/gcc.mk |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (45 lines):

diff -r 01eb58537655 -r 76e8b8200102 mk/compiler/gcc.mk
--- a/mk/compiler/gcc.mk        Tue Oct 03 08:33:56 2017 +0000
+++ b/mk/compiler/gcc.mk        Tue Oct 03 09:38:16 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.184 2017/09/11 09:06:41 jperkin Exp $
+# $NetBSD: gcc.mk,v 1.185 2017/10/03 09:38:16 jperkin Exp $
 #
 # This is the compiler definition for the GNU Compiler Collection.
 #
@@ -371,17 +371,6 @@
 CWRAPPERS_APPEND.ld+=  ${_RELRO_LDFLAGS}
 .endif
  
-# The user can choose the level of stack smashing protection.
-.if ${_GCC_VERSION:C/\..*$//} >= 4
-.  if ${PKGSRC_USE_SSP} == "all"
-_SSP_CFLAGS=           -fstack-protector-all
-.  elif ${PKGSRC_USE_SSP} == "strong"
-_SSP_CFLAGS=           -fstack-protector-strong
-.  else
-_SSP_CFLAGS=           -fstack-protector
-.  endif
-.endif
-
 _STACK_CHECK_CFLAGS=   -fstack-check
 
 .if ${_PKGSRC_USE_STACK_CHECK} == "yes"
@@ -877,6 +866,17 @@
 CC_VERSION=            ${_GCC_PKG}
 .endif
 
+# The user can choose the level of stack smashing protection.
+.if !empty(CC_VERSION:Mgcc-[4-9]*)
+.  if ${PKGSRC_USE_SSP} == "all"
+_SSP_CFLAGS=           -fstack-protector-all
+.  elif ${PKGSRC_USE_SSP} == "strong"
+_SSP_CFLAGS=           -fstack-protector-strong
+.  else
+_SSP_CFLAGS=           -fstack-protector
+.  endif
+.endif
+
 # Prepend the path to the compiler to the PATH.
 .if !empty(_LANGUAGES.gcc)
 PREPEND_PATH+= ${_GCC_DIR}/bin



Home | Main Index | Thread Index | Old Index