Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Feb 2003 12:43:23 -0600 (CST)
From:      Dan Nelson <dnelson@allantgroup.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        obrien@FreeBSD.org
Subject:   ports/48013: [PATCH] gcc-3.2.1 bounds-checking
Message-ID:  <200302061843.h16IhNFV072633@dan.emsphone.com>

next in thread | raw e-mail | index | archive | help

>Number:         48013
>Category:       ports
>Synopsis:       [PATCH] gcc-3.2.1 bounds-checking
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 06 10:50:06 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Dan Nelson
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 5.0-CURRENT FreeBSD 5.0-CURRENT #244: Wed Jan 22 17:15:36 CST 2003 dan@dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386


	
>Description:
Patches to the lang/gcc32 port that allow the user to build with Herman
ten Brugge's bounds-checking patches.

	
>How-To-Repeat:
	
>Fix:

Apply the following patch, and set WITH_BOUNDSCHECKING=yes before
building.  Herman's website http://web.inter.nl.net/hcc/Haj.Ten.Brugge/
has a patchset for gcc 3.2.2 already, so when the gcc32 port gets
updated, BCCPATCH will need to change also.

patch-va conflicts with the bounds-checking patch, so I had to split it
into two versions (opt.patch-va.gcc and opt.patch-va.gccbc).  which one
gets applied depends on whether WITH_BOUNDSCHECKING is set or not.

	

--- gcc32.diff begins here ---
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/lang/gcc32/Makefile,v
retrieving revision 1.137
diff -u -r1.137 Makefile
--- Makefile	3 Dec 2002 23:21:14 -0000	1.137
+++ Makefile	6 Feb 2003 18:29:42 -0000
@@ -13,7 +13,8 @@
 PORTVERSION=	3.2.1
 PORTREVISION=	${SNAPVER}
 CATEGORIES=	lang java
-MASTER_SITES=	${MASTER_SITE_GCC}
+MASTER_SITES=	${MASTER_SITE_GCC} \
+		http://web.inter.NL.net/hcc/Haj.Ten.Brugge/:bgcc
 MASTER_SITE_SUBDIR=	releases/gcc-${PORTVERSION}
 DISTFILES=	gcc-core-${PORTVERSION}${EXTRACT_SUFX} \
 		gcc-g++-${PORTVERSION}${EXTRACT_SUFX} \
@@ -21,6 +22,19 @@
 		gcc-java-${PORTVERSION}${EXTRACT_SUFX} \
 		gcc-objc-${PORTVERSION}${EXTRACT_SUFX}
 
+# WITH_BOUNDSCHECKING=	yes
+
+.if defined (WITH_BOUNDSCHECKING)
+# Fetch another file, but don't extract it.  The patch modifies
+# Makefile.in, so there are two versions of patch-va.
+BCCPATCH=	bounds-checking-gcc-3.2.1-1.01.patch.bz2
+DISTFILES+=	${BCCPATCH}:bgcc
+EXTRACT_ONLY=	${DISTFILES:S/${BCCPATCH}:bgcc//}
+EXTRA_PATCHES=	${FILESDIR}/opt.patch-gccbc-aa ${FILESDIR}/opt.patch-va.gccbc
+.else
+EXTRA_PATCHES=	${FILESDIR}/opt.patch-va.gcc
+.endif
+
 #PATCH_SITES=	ftp://relay.nuxi.com/obrien/
 #PATCHFILES=	port_gcc32_${SNAPDATE}.diff
 
@@ -32,9 +46,9 @@
 
 PATCH_WRKSRC=	${SRCDIR}
 CONFIGURE_SCRIPT=	../${SRCDIR:C/${WRKDIR}//}/configure
-# do not require Gcc 3.2 to compile -- or we have an infinate loop on RELENG_4.
+# do not require Gcc 3.2 to compile -- or we have an infinite loop on RELENG_4.
 USE_GCC=	X
-NOMANCOMPRESS=	yes	# to hard to deal with differences on 5-cur and releng4
+NOMANCOMPRESS=	yes	# too hard to deal with differences on 5-cur and releng4
 
 .include <bsd.port.pre.mk>
 
@@ -77,6 +91,11 @@
 
 pre-fetch:
 	@${ECHO} "Making GCC ${DISTNAME:S/^gcc-//} for ${OPSYS} ${OSREL} ${PORTOBJFORMAT}	target ${CONFIGURE_TARGET}"
+.if !defined(WITH_BOUNDSCHECKING)
+	@${ECHO_MSG} "You can enable fine-grained bounds-checking support for compiled C programs"
+	@${ECHO_MSG} "by defining WITH_BOUNDSCHECKING.  Compile and link with \"-fbounds-checking\""
+	@${ECHO_MSG} "to use."
+.endif
 
 .if defined(CVS_DATE)
 DIST_SUBDIR=	${PKGNAME}
@@ -108,6 +127,16 @@
 	${MKDIR} ${SRCDIR}
 	cd ${DISTDIR}/${DIST_SUBDIR}/gcc ; pax -pe -rwt . ${SRCDIR}
 .endif	# CVS_DATE
+
+.if defined(WITH_BOUNDSCHECKING)
+# Extract bounds-checking patch, removing the ada parts of the patch with sed.
+pre-patch:
+	(	cd ${_DISTDIR} && \
+		${BZCAT} ${BCCPATCH} | \
+			${SED} -e '/^--- .*ada/,/^diff/d' | \
+			${PATCH} -d ${PATCH_WRKSRC} -E -p1 --quiet \
+	)
+.endif
 
 pre-configure:
 	@# Keep from running `autoconf' and `autoheader' since we modified
Index: distinfo
===================================================================
RCS file: /home/ncvs/ports/lang/gcc32/distinfo,v
retrieving revision 1.76
diff -u -r1.76 distinfo
--- distinfo	26 Nov 2002 01:59:10 -0000	1.76
+++ distinfo	19 Dec 2002 03:09:11 -0000
@@ -3,3 +3,4 @@
 MD5 (gcc-g77-3.2.1.tar.bz2) = db0b9bd892cdba585e0694050a8abcd8
 MD5 (gcc-java-3.2.1.tar.bz2) = 46cb5368ab181df7288b186597871db2
 MD5 (gcc-objc-3.2.1.tar.bz2) = 5c82691527eeec787917041e0598627a
+MD5 (bounds-checking-gcc-3.2.1-1.01.patch.bz2) = ec4e752d0daab3e4d477d45e867dc886
Index: files/opt.patch-gccbc-aa
===================================================================
RCS file: files/opt.patch-gccbc-aa
diff -N files/opt.patch-gccbc-aa
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/opt.patch-gccbc-aa	13 Jun 2002 16:38:31 -0000
@@ -0,0 +1,11 @@
+--- gcc/bounds/lib/malloc/Makefile.orig	Fri Sep 28 15:31:19 2001
++++ gcc/bounds/lib/malloc/Makefile	Mon Oct  1 13:58:20 2001
+@@ -52,7 +52,7 @@ VPATH = $(srcdir)/bounds/lib/malloc
+ SUBDIR_INCLUDES = -I$(srcdir)/bounds/lib/malloc -I../../.. -I$(srcdir) -I$(srcdir)/config -I../../../../include
+ 
+ # Use this on System V.
+-CPPFLAGS = -DUSG
++CPPFLAGS = -DBSD4_2
+ 
+ .c.o:
+ 	$(GCC_FOR_TARGET) -Wall $(OPTIMIZE) $(CPPFLAGS) \
Index: files/opt.patch-va.gcc
===================================================================
RCS file: files/opt.patch-va.gcc
diff -N files/opt.patch-va.gcc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/opt.patch-va.gcc	25 Nov 2002 22:05:54 -0000
@@ -0,0 +1,20 @@
+--- gcc/Makefile.in.orig	Thu May 23 10:57:21 2002
++++ gcc/Makefile.in	Tue Sep 10 19:52:35 2002
+@@ -156,6 +156,3 @@
+ # to programs compiled with GCC.
+-USER_H = $(srcdir)/ginclude/stdarg.h $(srcdir)/ginclude/stddef.h \
+-    $(srcdir)/ginclude/varargs.h \
+-    $(srcdir)/ginclude/stdbool.h $(srcdir)/ginclude/iso646.h \
+-    $(EXTRA_HEADERS)
++USER_H = $(EXTRA_HEADERS)
+ 
+@@ -858,3 +855,3 @@
+ $(srcdir)/configure: @MAINT@ $(srcdir)/configure.in
+-	(cd $(srcdir) && autoconf)
++	(cd $(srcdir) && echo "wants to run autoconf, blah")
+ 
+@@ -880,3 +877,3 @@
+ @MAINT@ $(srcdir)/cstamp-h.in: $(srcdir)/configure.in $(srcdir)/acconfig.h
+-@MAINT@	(cd $(srcdir) && autoheader)
++@MAINT@	(cd $(srcdir) && echo "wants to run autoheader, blah")
+ @MAINT@	@rm -f $(srcdir)/cstamp-h.in
Index: files/opt.patch-va.gccbc
===================================================================
RCS file: files/opt.patch-va.gccbc
diff -N files/opt.patch-va.gccbc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/opt.patch-va.gccbc	25 Nov 2002 17:36:42 -0000
@@ -0,0 +1,32 @@
+--- gcc/Makefile.in.orig	Mon Nov 25 11:22:42 2002
++++ gcc/Makefile.in	Mon Nov 25 11:31:02 2002
+@@ -154,10 +154,7 @@ INSTALL_HEADERS_DIR = @build_install_hea
+ 
+ # Header files that are made available under the same name
+ # to programs compiled with GCC.
+-USER_H = $(srcdir)/ginclude/stdarg.h $(srcdir)/ginclude/stddef.h \
+-    $(srcdir)/ginclude/varargs.h \
+-    $(srcdir)/ginclude/stdbool.h $(srcdir)/ginclude/iso646.h \
+-    $(srcdir)/ginclude/unchecked.h $(EXTRA_HEADERS)
++USER_H = $(srcdir)/ginclude/unchecked.h $(EXTRA_HEADERS)
+ 
+ # The GCC to use for compiling libgcc.a, enquire, and crt*.o.
+ # Usually the one we just built.
+@@ -861,7 +858,7 @@ cs-tm_p.h: Makefile
+ # then do allow autoconf to be run.
+ 
+ $(srcdir)/configure: @MAINT@ $(srcdir)/configure.in
+-	(cd $(srcdir) && autoconf)
++	(cd $(srcdir) && echo "wants to run autoconf, blah")
+ 
+ gccbug:	$(srcdir)/gccbug.in
+ 	CONFIG_FILES=gccbug CONFIG_HEADERS= ./config.status
+@@ -883,7 +880,7 @@ mklibgcc: $(srcdir)/mklibgcc.in
+ # Only run it if maintainer mode is enabled.
+ @MAINT@ $(srcdir)/config.in: $(srcdir)/cstamp-h.in
+ @MAINT@ $(srcdir)/cstamp-h.in: $(srcdir)/configure.in $(srcdir)/acconfig.h
+-@MAINT@	(cd $(srcdir) && autoheader)
++@MAINT@	(cd $(srcdir) && echo "wants to run autoheader, blah")
+ @MAINT@	@rm -f $(srcdir)/cstamp-h.in
+ @MAINT@	echo timestamp > $(srcdir)/cstamp-h.in
+ auto-host.h: cstamp-h ; @true
Index: files/patch-va
===================================================================
RCS file: files/patch-va
diff -N files/patch-va
--- files/patch-va	11 Sep 2002 16:48:58 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
---- gcc/Makefile.in.orig	Thu May 23 10:57:21 2002
-+++ gcc/Makefile.in	Tue Sep 10 19:52:35 2002
-@@ -156,6 +156,3 @@
- # to programs compiled with GCC.
--USER_H = $(srcdir)/ginclude/stdarg.h $(srcdir)/ginclude/stddef.h \
--    $(srcdir)/ginclude/varargs.h \
--    $(srcdir)/ginclude/stdbool.h $(srcdir)/ginclude/iso646.h \
--    $(EXTRA_HEADERS)
-+USER_H = $(EXTRA_HEADERS)
- 
-@@ -858,3 +855,3 @@
- $(srcdir)/configure: @MAINT@ $(srcdir)/configure.in
--	(cd $(srcdir) && autoconf)
-+	(cd $(srcdir) && echo "wants to run autoconf, blah")
- 
-@@ -880,3 +877,3 @@
- @MAINT@ $(srcdir)/cstamp-h.in: $(srcdir)/configure.in $(srcdir)/acconfig.h
--@MAINT@	(cd $(srcdir) && autoheader)
-+@MAINT@	(cd $(srcdir) && echo "wants to run autoheader, blah")
- @MAINT@	@rm -f $(srcdir)/cstamp-h.in
--- gcc32.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302061843.h16IhNFV072633>