View | Details | Raw Unified | Return to bug 148228
Collapse All | Expand All

(-)Makefile (-10 / +8 lines)
Lines 6-27 Link Here
6
#
6
#
7
7
8
PORTNAME=	ccache
8
PORTNAME=	ccache
9
PORTVERSION=	2.4
9
PORTVERSION=	3.0
10
PORTREVISION=	9
11
CATEGORIES=	devel
10
CATEGORIES=	devel
12
MASTER_SITES=	http://samba.org/ftp/ccache/
11
MASTER_SITES=	http://samba.org/ftp/ccache/
13
12
14
MAINTAINER=	ahze@FreeBSD.org
13
MAINTAINER=	ahze@FreeBSD.org
15
COMMENT=	A tool to minimize the compile time of C/C++ programs
14
COMMENT=	A tool to minimize the compile time of C/C++ programs
16
15
16
LICENSE=	GPLv3
17
LICENSE_FILE=	${WRKSRC}/COPYING
18
17
GNU_CONFIGURE=	yes
19
GNU_CONFIGURE=	yes
18
20
19
MAN1=		ccache.1
21
MAN1=		ccache.1
20
PLIST_FILES=	bin/ccache
22
PLIST_FILES=	bin/ccache
21
23
22
PORTDOCS=	index.html \
24
PORTDOCS=	*
23
		ccache-man.html \
24
		${HOWTO}
25
25
26
.if !defined(WITHOUT_COMPILER_LINKS)
26
.if !defined(WITHOUT_COMPILER_LINKS)
27
HOWTO=		ccache-howto-freebsd.txt
27
HOWTO=		ccache-howto-freebsd.txt
Lines 34-42 Link Here
34
34
35
.if !defined(WITHOUT_COMPILER_LINKS)
35
.if !defined(WITHOUT_COMPILER_LINKS)
36
.if ${ARCH}=="i386"
36
.if ${ARCH}=="i386"
37
CCACHE_COMPILERS+=      icc icpc
37
CCACHE_COMPILERS+=	icc icpc
38
.endif
38
.endif
39
GNU_COMPILERS+=		34 42 43 44 -ooo
39
GNU_COMPILERS+=		34 42 43 44 45 46
40
CCACHE_COMPILERS+=	cc c++ gcc g++ ${GNU_COMPILERS:S|^|gcc|} ${GNU_COMPILERS:S|^|g++|}
40
CCACHE_COMPILERS+=	cc c++ gcc g++ ${GNU_COMPILERS:S|^|gcc|} ${GNU_COMPILERS:S|^|g++|}
41
.if defined(EXTRA_COMPILERS)
41
.if defined(EXTRA_COMPILERS)
42
CCACHE_COMPILERS+=	${EXTRA_COMPILERS}
42
CCACHE_COMPILERS+=	${EXTRA_COMPILERS}
Lines 78-86 Link Here
78
.endif
78
.endif
79
.if !defined(NOPORTDOCS)
79
.if !defined(NOPORTDOCS)
80
	@${MKDIR} ${DOCSDIR}
80
	@${MKDIR} ${DOCSDIR}
81
.for i in ${PORTDOCS:S/${HOWTO}//}
81
	${INSTALL_DATA} ${WRKSRC}/manual.html ${DOCSDIR}
82
	${INSTALL_DATA} ${WRKSRC}/web/${i} ${DOCSDIR}
83
.endfor
84
.if !defined(WITHOUT_COMPILER_LINKS)
82
.if !defined(WITHOUT_COMPILER_LINKS)
85
	${INSTALL_DATA} ${WRKDIR}/${HOWTO} ${DOCSDIR}
83
	${INSTALL_DATA} ${WRKDIR}/${HOWTO} ${DOCSDIR}
86
.endif
84
.endif
(-)distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
MD5 (ccache-2.4.tar.gz) = 73c1ed1e767c1752dd0f548ec1e66ce7
1
MD5 (ccache-3.0.tar.gz) = 98145b8ad69a96bf1abf9a52d550e507
2
SHA256 (ccache-2.4.tar.gz) = 435f862ca5168c346f5aa9e242174bbf19a5abcaeecfceeac2f194558827aaa0
2
SHA256 (ccache-3.0.tar.gz) = f3dd72457fc35bc8edc3630399fb1f6117b43349e8ac6fcfad575c46add32856
3
SIZE (ccache-2.4.tar.gz) = 86363
3
SIZE (ccache-3.0.tar.gz) = 264888
(-)files/patch-ccache.1 (-19 lines)
Removed Link Here
1
--- ccache.1.orig	Mon Sep 13 06:38:30 2004
2
+++ ccache.1	Tue Nov 15 14:59:46 2005
3
@@ -234,6 +234,16 @@
4
 incorrect setting of this debug info rarely causes problems\&. If you
5
 strike problems with gdb not using the correct directory then enable
6
 this option\&.
7
+.IP
8
+.IP "\fBCCACHE_NOHASH_SIZE_MTIME\fP"
9
+This tells ccache to not hash the real compiler's size and modification
10
+time. Normally this is the mechanism to detect compiler upgrades.
11
+There are situations however, where even though the compiler's size or
12
+modification time has changed you can safely use the cached objects
13
+(e.g. if as part of your build system the compiler is built as well
14
+and the compiler's source has not changed; or if the compiler has only
15
+changes that do not affect code generation). Use this feature only if
16
+you know what you are doing.
17
 .IP 
18
 .IP "\fBCCACHE_UNIFY\fP" 
19
 If you set the environment variable CCACHE_UNIFY
(-)files/patch-ccache.c (-17 lines)
Removed Link Here
1
--- ccache.c.orig	2004/09/13 10:19:06	1.96
2
+++ ccache.c	2005/11/24 21:54:09	1.98
3
@@ -331,8 +331,12 @@
4
 		hash_string(str_basename(args->argv[0]));
5
 	}
6
 
7
-	hash_int(st.st_size);
8
-	hash_int(st.st_mtime);
9
+	if (getenv("CCACHE_HASH_COMPILER")) {
10
+		hash_file(args->argv[0]);
11
+	} else if (!getenv("CCACHE_NOHASH_SIZE_MTIME")) {
12
+		hash_int(st.st_size);
13
+		hash_int(st.st_mtime);
14
+	}
15
 
16
 	/* possibly hash the current working directory */
17
 	if (getenv("CCACHE_HASHDIR")) {
(-)files/patch-ccache.yo (-14 lines)
Removed Link Here
1
--- ccache.yo.orig	2004/09/10 05:05:14	1.26
2
+++ ccache.yo	2005/11/24 21:54:09	1.27
3
@@ -203,6 +203,11 @@
4
 strike problems with gdb not using the correct directory then enable
5
 this option.
6
 
7
+dit(bf(CCACHE_HASH_COMPILER)) This tells ccache to hash binary of the
8
+compiler instead of hashing just its size and mtime. This is very
9
+slightly slower, but makes copes better with compiler upgrades during
10
+a build bootstrapping process.
11
+
12
 dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY
13
 then ccache will use the C/C++ unifier when hashing the pre-processor
14
 output if -g is not used in the compile. The unifier is slower than a
(-)files/patch-md4 (-148 lines)
Removed Link Here
1
--- ccache.h.orig	Wed Sep  8 21:30:40 2004
2
+++ ccache.h	Wed Sep  8 21:31:53 2004
3
@@ -65,14 +65,14 @@
4
 
5
 typedef unsigned uint32;
6
 
7
-#include "mdfour.h"
8
+#include <md4.h> 
9
 
10
 void hash_start(void);
11
 void hash_string(const char *s);
12
 void hash_int(int x);
13
 void hash_file(const char *fname);
14
 char *hash_result(void);
15
-void hash_buffer(const char *s, int len);
16
+void hash_buffer(const unsigned char *s, unsigned int len);
17
 
18
 void cc_log(const char *format, ...);
19
 void fatal(const char *msg);
20
--- hash.c.orig	2004-09-13 12:38:30.000000000 +0200
21
+++ hash.c	2009-07-21 23:37:00.000000000 +0200
22
@@ -20,17 +20,22 @@
23
 */
24
 
25
 #include "ccache.h"
26
+#include <sys/types.h>
27
+#include <sys/mman.h>
28
+#include <sys/stat.h>
29
 
30
-static struct mdfour md;
31
+static MD4_CTX md;
32
+static off_t   totalN;
33
 
34
-void hash_buffer(const char *s, int len)
35
+void hash_buffer(const unsigned char *s, unsigned int len)
36
 {
37
-	mdfour_update(&md, (unsigned char *)s, len);
38
+       totalN += len;
39
+       MD4Update(&md, s, len);
40
 }
41
 
42
 void hash_start(void)
43
 {
44
-	mdfour_begin(&md);
45
+	MD4Init(&md);
46
 }
47
 
48
 void hash_string(const char *s)
49
@@ -46,35 +51,44 @@
50
 /* add contents of a file to the hash */
51
 void hash_file(const char *fname)
52
 {
53
-	char buf[1024];
54
-	int fd, n;
55
+       char *buf;
56
+       int fd;
57
+       struct stat stats;
58
 
59
 	fd = open(fname, O_RDONLY|O_BINARY);
60
 	if (fd == -1) {
61
 		cc_log("Failed to open %s\n", fname);
62
-		fatal("hash_file");
63
+                fatal(__FUNCTION__);
64
 	}
65
 
66
-	while ((n = read(fd, buf, sizeof(buf))) > 0) {
67
-		hash_buffer(buf, n);
68
-	}
69
+       if (fstat(fd, &stats) != 0) {
70
+               cc_log("Failed to fstat the opened %s (descriptor %d)\n",
71
+                       fname, fd);
72
+               close(fd);
73
+               fatal(__FUNCTION__);
74
+       }
75
+       if( stats.st_size == 0 )
76
+	       buf = NULL;
77
+       else {
78
+	       buf = mmap(NULL, stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 
79
+	       if (buf == MAP_FAILED) {
80
+		       cc_log("Failed to mmap %s\n", fname);
81
+		       close(fd);
82
+		       fatal(__FUNCTION__);
83
+		}       
84
+       }
85
+
86
+        hash_buffer(buf, stats.st_size);
87
 	close(fd);
88
 }
89
 
90
 /* return the hash result as a static string */
91
 char *hash_result(void)
92
 {
93
-	unsigned char sum[16];
94
 	static char ret[53];
95
-	int i;
96
 
97
-	hash_buffer(NULL, 0);
98
-	mdfour_result(&md, sum);
99
+        MD4End(&md, ret);
100
 	
101
-	for (i=0;i<16;i++) {
102
-		sprintf(&ret[i*2], "%02x", (unsigned)sum[i]);
103
-	}
104
-	sprintf(&ret[i*2], "-%u", (unsigned)md.totalN);
105
-
106
+        snprintf(ret + 32, sizeof ret - 32, "-%lu", (unsigned long)totalN);
107
 	return ret;
108
 }
109
--- unify.c.orig	Wed Sep  8 21:36:41 2004
110
+++ unify.c	Wed Sep  8 21:37:20 2004
111
@@ -104,13 +104,12 @@
112
 			hash_buffer((char *)buf, len);
113
 			len = 0;
114
 		}
115
-		hash_buffer(NULL, 0);
116
 		return;
117
 	}
118
 
119
 	buf[len++] = c;
120
-	if (len == 64) {
121
-		hash_buffer((char *)buf, len);
122
+       if (len == sizeof buf) {
123
+                hash_buffer((char *)buf, sizeof buf);
124
 		len = 0;
125
 	}
126
 }
127
--- Makefile.in.orig	Mon Sep  6 09:04:22 2004
128
+++ Makefile.in	Wed Sep  8 21:41:00 2004
129
@@ -11,16 +11,16 @@
130
 CFLAGS=@CFLAGS@ -I.
131
 EXEEXT=@EXEEXT@
132
 
133
-OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
134
+OBJS= ccache.o hash.o execute.o util.o args.o stats.o \
135
 	cleanup.o snprintf.o unify.o
136
-HEADERS = ccache.h mdfour.h
137
+HEADERS = ccache.h
138
 
139
 all: ccache$(EXEEXT)
140
 
141
 docs: ccache.1 web/ccache-man.html
142
 
143
 ccache$(EXEEXT): $(OBJS) $(HEADERS)
144
-	$(CC) $(CFLAGS) -o $@ $(OBJS)
145
+	$(CC) $(CFLAGS) -o $@ $(OBJS) -lmd
146
 
147
 ccache.1: ccache.yo
148
 	-yodl2man -o ccache.1 ccache.yo
(-)files/patch-util.c (-25 lines)
Removed Link Here
1
$MirOS: ports/devel/ccache/patches/patch-util_c,v 1.1 2008/10/05 17:03:37 tg Exp $
2
3
	Very interesting bug: tries to read “size” bytes
4
	from “ptr” (of size “oldsize”) while copying to
5
	“p2” (of size “size”), instead of “oldsize” bytes;
6
	with mmap malloc, jemalloc, and possibly omalloc,
7
	the additional RAM needed is not always in core…
8
9
--- util.c.orig	Mon Sep 13 10:38:08 2004
10
+++ util.c	Sun Oct  5 16:58:39 2008
11
@@ -187,13 +187,9 @@ void *x_realloc(void *ptr, size_t size)
12
 {
13
 	void *p2;
14
 	if (!ptr) return x_malloc(size);
15
-	p2 = malloc(size);
16
+	p2 = realloc(ptr, size);
17
 	if (!p2) {
18
 		fatal("out of memory in x_realloc");
19
-	}
20
-	if (ptr) {
21
-		memcpy(p2, ptr, size);
22
-		free(ptr);
23
 	}
24
 	return p2;
25
 }
(-)files/pkg-message.in (+3 lines)
Lines 3-5 Link Here
3
Please read %%DOCSDIR%%/%%HOWTO%% for 
3
Please read %%DOCSDIR%%/%%HOWTO%% for 
4
information on using ccache with FreeBSD ports and src.
4
information on using ccache with FreeBSD ports and src.
5
5
6
If you are upgrading from 2.4 release you might clear
7
the old cache directory with "ccache --clear".
8
(-)files/world-c++.in (-1 / +1 lines)
Lines 1-4 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
unset CCACHE_PATH
2
unset CCACHE_PATH
3
export CCACHE_HASH_COMPILER
3
export CCACHE_COMPILERCHECK=content
4
exec %%PREFIX%%/%%CCLINKDIR%%/c++ "$@"
4
exec %%PREFIX%%/%%CCLINKDIR%%/c++ "$@"
(-)files/world-cc.in (-1 / +1 lines)
Lines 1-4 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
unset CCACHE_PATH
2
unset CCACHE_PATH
3
export CCACHE_HASH_COMPILER
3
export CCACHE_COMPILERCHECK=content
4
exec %%PREFIX%%/%%CCLINKDIR%%/cc "$@"
4
exec %%PREFIX%%/%%CCLINKDIR%%/cc "$@"

Return to bug 148228