summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorkhorben <khorben@pkgsrc.org>2015-07-26 22:13:17 +0000
committerkhorben <khorben@pkgsrc.org>2015-07-26 22:13:17 +0000
commit3098266ee9c6f169aeaa48359ab80d32a2150d59 (patch)
treed2a51992cf041582786d2ec545c7cb45584d560c /mk
parent6d02600cec5fee755bb72c3bf720d6408083ee58 (diff)
downloadpkgsrc-3098266ee9c6f169aeaa48359ab80d32a2150d59.tar.gz
Add support for compiling with stack-smashing protection
This is enabled with PKGSRC_USE_SSP in mk.conf(5), as documented there. Most NetBSD platforms are supported (when compiling with gcc). After consensus on tech-pkg@.
Diffstat (limited to 'mk')
-rw-r--r--mk/compiler/gcc.mk6
-rw-r--r--mk/defaults/mk.conf7
-rw-r--r--mk/platform/NetBSD.mk12
3 files changed, 21 insertions, 4 deletions
diff --git a/mk/compiler/gcc.mk b/mk/compiler/gcc.mk
index 7e42b33eba3..3fb8532fd24 100644
--- a/mk/compiler/gcc.mk
+++ b/mk/compiler/gcc.mk
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.162 2015/07/16 12:09:04 ryoon Exp $
+# $NetBSD: gcc.mk,v 1.163 2015/07/26 22:13:17 khorben Exp $
#
# This is the compiler definition for the GNU Compiler Collection.
#
@@ -67,7 +67,7 @@ _DEF_VARS.gcc= \
PKG_CC PKG_CPP PKG_CXX PKG_FC \
PKG_ADA PKG_GMK PKG_GLK PKG_GDB PKG_CHP PKG_GLK PKG_GNT PKG_PRP \
_CC _COMPILER_RPATH_FLAG _COMPILER_STRIP_VARS \
- _GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CC \
+ _GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CC _GCC_CFLAGS \
_GCC_CPP _GCC_CXX _GCC_DEPENDENCY _GCC_DEPENDS \
_GCC_FC _GCC_LDFLAGS _GCC_LIBDIRS _GCC_PKG \
_GCC_PKGBASE _GCC_PKGSRCDIR _GCC_PKG_SATISFIES_DEP \
@@ -348,6 +348,8 @@ CWRAPPERS_APPEND.cc+= -std=gnu99
CFLAGS+= -Wno-import
.endif
+CFLAGS+= ${_GCC_CFLAGS}
+
.if !empty(_NEED_GCC2:M[yY][eE][sS])
#
# We require gcc-2.x in the lang/gcc2 directory.
diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf
index 31f72fe29cc..e87e114a4a4 100644
--- a/mk/defaults/mk.conf
+++ b/mk/defaults/mk.conf
@@ -1,4 +1,4 @@
-# $NetBSD: mk.conf,v 1.257 2015/07/04 16:18:38 joerg Exp $
+# $NetBSD: mk.conf,v 1.258 2015/07/26 22:13:17 khorben Exp $
#
# This file provides default values for variables that may be overridden
@@ -215,6 +215,11 @@ PKGSRC_RUN_TEST?= no
# Possible: yes, no
# Default: no
+PKGSRC_USE_SSP?= no
+# Set this to YES to enable stack-smashing protection (on supported platforms).
+# Possible: yes, no
+# Default: no
+
.if (!empty(MACHINE_PLATFORM:MNetBSD-*-*) && \
exists(/usr/X11R7/lib/libX11.so))
PREFER_PKGSRC?=
diff --git a/mk/platform/NetBSD.mk b/mk/platform/NetBSD.mk
index c83b5d5c5dc..8a0cda4dd43 100644
--- a/mk/platform/NetBSD.mk
+++ b/mk/platform/NetBSD.mk
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.mk,v 1.42 2015/05/26 10:08:37 joerg Exp $
+# $NetBSD: NetBSD.mk,v 1.43 2015/07/26 22:13:17 khorben Exp $
#
# Variable definitions for the NetBSD operating system.
@@ -128,6 +128,16 @@ FFLAGS+= -mieee
PKG_HAVE_KQUEUE= # defined
.endif
+.if (${MACHINE_ARCH} != "alpha") && \
+ (${MACHINE_ARCH} != "hppa") && \
+ (${MACHINE_ARCH} != "ia64") && \
+ (${MACHINE_ARCH} != "mips")
+. if ${PKGSRC_USE_SSP:Uno} != "no"
+# build with stack protection (with GCC)
+_GCC_CFLAGS+= -fstack-protector
+. endif
+.endif
+
_OPSYS_CAN_CHECK_SHLIBS= yes # use readelf in check/bsd.check-vars.mk
# check for maximum command line length and set it in configure's environment,