From: Andrew Tridgell Date: Mon, 29 Apr 2002 09:12:46 +0000 (+0200) Subject: - disabled unifier by default (to get warnings right) X-Git-Tag: v1.8~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df51b129d1ffbd98020350b47bc04b6cf0387ac2;p=thirdparty%2Fccache.git - disabled unifier by default (to get warnings right) - fixed md4 code - updated docs --- diff --git a/ccache.1 b/ccache.1 index c0b6aa44d..4eae543de 100644 --- a/ccache.1 +++ b/ccache.1 @@ -106,6 +106,9 @@ This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin)\&. After installing you may wish to run "which gcc" to make sure that the correct link is being used\&. .PP +Note! Do not use a hard link, use a symbolic link\&. A hardlink will +cause "interesting" problems\&. +.PP .SH "ENVIRONMENT VARIABLES" .PP ccache used a number of environment variables to control operation\&. In @@ -162,16 +165,18 @@ instead\&. The main reason for setting this option is to avoid the update of the modification time on object files that are the result of the same compilation in a different directory\&. .IP -.IP "\fBCCACHE_NOUNIFY\fP" -If you set the environment variable -CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing -the pre-processor output\&. The unifier is slower than a normal hash, so -setting this environment variable gains a little bit of speed, but it -means that ccache can\&'t take advantage of not recompiling when the -changes to the source code consist of reformatting only\&. Note that -using CCACHE_NOUNIFY changes the hash, so cached compiles with -CCACHE_NOUNIFY set cannot be used when CCACHE_NOUNIFY is not set and -vice versa\&. +.IP "\fBCCACHE_UNIFY\fP" +If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile\&. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only\&. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa\&. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages\&. .IP .PP .SH "CACHE SIZE MANAGEMENT" diff --git a/ccache.c b/ccache.c index 33536026b..49668dd14 100644 --- a/ccache.c +++ b/ccache.c @@ -263,8 +263,11 @@ static void find_hash(ARGS *args) preprocessor output, which means we are sensitive to line number information. Otherwise we can discard line number info, which makes us less sensitive to reformatting changes + + Note! I have now disabled the unification code by default + as it gives the wrong line numbers for warnings. Pity. */ - if (found_debug || getenv("CCACHE_NOUNIFY")) { + if (found_debug || !getenv("CCACHE_UNIFY")) { hash_file(path_stdout); } else { if (unify_hash(path_stdout) != 0) { diff --git a/ccache.h b/ccache.h index acd111311..f7b4f80e9 100644 --- a/ccache.h +++ b/ccache.h @@ -1,4 +1,4 @@ -#define CCACHE_VERSION "1.7" +#define CCACHE_VERSION "1.8" #include "config.h" diff --git a/ccache.yo b/ccache.yo index a6fae7b1f..c9d0b3290 100644 --- a/ccache.yo +++ b/ccache.yo @@ -89,6 +89,9 @@ This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin). After installing you may wish to run "which gcc" to make sure that the correct link is being used. +Note! Do not use a hard link, use a symbolic link. A hardlink will +cause "interesting" problems. + manpagesection(ENVIRONMENT VARIABLES) ccache used a number of environment variables to control operation. In @@ -138,15 +141,17 @@ instead. The main reason for setting this option is to avoid the update of the modification time on object files that are the result of the same compilation in a different directory. -dit(bf(CCACHE_NOUNIFY)) If you set the environment variable -CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing -the pre-processor output. The unifier is slower than a normal hash, so -setting this environment variable gains a little bit of speed, but it -means that ccache can't take advantage of not recompiling when the -changes to the source code consist of reformatting only. Note that -using CCACHE_NOUNIFY changes the hash, so cached compiles with -CCACHE_NOUNIFY set cannot be used when CCACHE_NOUNIFY is not set and -vice versa. +dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages. enddit() diff --git a/hash.c b/hash.c index 4dbed4c9e..2c56b7962 100644 --- a/hash.c +++ b/hash.c @@ -25,44 +25,9 @@ static struct mdfour md; void hash_buffer(const char *s, int len) { - static char tail[64]; - static int tail_len; - - /* s == NULL means push the last chunk */ - if (s == NULL) { - if (tail_len > 0) { - mdfour_update(&md, (unsigned char *)tail, tail_len); - tail_len = 0; - } - return; - } - - if (tail_len) { - int n = 64-tail_len; - if (n > len) n = len; - memcpy(tail+tail_len, s, n); - tail_len += n; - len -= n; - s += n; - if (tail_len == 64) { - mdfour_update(&md, (unsigned char *)tail, 64); - tail_len = 0; - } - } - - while (len >= 64) { - mdfour_update(&md, (unsigned char *)s, 64); - s += 64; - len -= 64; - } - - if (len) { - memcpy(tail, s, len); - tail_len = len; - } + mdfour_update(&md, (unsigned char *)s, len); } - void hash_start(void) { mdfour_begin(&md); diff --git a/mdfour.c b/mdfour.c index 5b9c6903b..d0b47b62e 100644 --- a/mdfour.c +++ b/mdfour.c @@ -107,6 +107,7 @@ void mdfour_begin(struct mdfour *md) md->C = 0x98badcfe; md->D = 0x10325476; md->totalN = 0; + md->tail_len = 0; } @@ -143,6 +144,26 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) m = md; + if (in == NULL) { + mdfour_tail(md->tail, md->tail_len); + return; + } + + if (md->tail_len) { + int len = 64 - md->tail_len; + if (len > n) len = n; + memcpy(md->tail+md->tail_len, in, len); + md->tail_len += len; + n -= len; + in += len; + if (md->tail_len == 64) { + copy64(M, md->tail); + mdfour64(M); + m->totalN += 64; + md->tail_len = 0; + } + } + while (n >= 64) { copy64(M, in); mdfour64(M); @@ -151,7 +172,10 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) m->totalN += 64; } - mdfour_tail(in, n); + if (n) { + memcpy(md->tail, in, n); + md->tail_len = n; + } } @@ -166,11 +190,12 @@ void mdfour_result(struct mdfour *md, unsigned char *out) } -void mdfour(unsigned char *out, unsigned char *in, int n) +void mdfour(unsigned char *out, const unsigned char *in, int n) { struct mdfour md; mdfour_begin(&md); mdfour_update(&md, in, n); + mdfour_update(&md, NULL, 0); mdfour_result(&md, out); } @@ -179,26 +204,31 @@ static void file_checksum1(char *fname) { int fd, i; struct mdfour md; - unsigned char buf[64*1024], sum[16]; + unsigned char buf[1024], sum[16]; + unsigned chunk; fd = open(fname,O_RDONLY); if (fd == -1) { perror("fname"); exit(1); } + + chunk = 1 + random() % (sizeof(buf) - 1); mdfour_begin(&md); while (1) { - int n = read(fd, buf, sizeof(buf)); + int n = read(fd, buf, chunk); if (n >= 0) { mdfour_update(&md, buf, n); } - if (n < sizeof(buf)) break; + if (n < chunk) break; } close(fd); + mdfour_update(&md, NULL, 0); + mdfour_result(&md, sum); for (i=0;i<16;i++) diff --git a/mdfour.h b/mdfour.h index 6cc9aae3b..92ef2f831 100644 --- a/mdfour.h +++ b/mdfour.h @@ -22,12 +22,14 @@ struct mdfour { uint32 A, B, C, D; uint32 totalN; + unsigned char tail[64]; + unsigned tail_len; }; void mdfour_begin(struct mdfour *md); void mdfour_update(struct mdfour *md, const unsigned char *in, int n); void mdfour_result(struct mdfour *md, unsigned char *out); -void mdfour(unsigned char *out, unsigned char *in, int n); +void mdfour(unsigned char *out, const unsigned char *in, int n); diff --git a/web/ccache-man.html b/web/ccache-man.html index 39514cbae..7cd9cf6ce 100644 --- a/web/ccache-man.html +++ b/web/ccache-man.html @@ -94,6 +94,8 @@ in your path. This will work as long as /usr/local/bin comes before the path to gcc (which is usually in /usr/bin). After installing you may wish to run "which gcc" to make sure that the correct link is being used. +

Note! Do not use a hard link, use a symbolic link. A hardlink will +cause "interesting" problems.

ENVIRONMENT VARIABLES

ccache used a number of environment variables to control operation. In @@ -133,15 +135,17 @@ directory when creating the compiler output and will do a file copy instead. The main reason for setting this option is to avoid the update of the modification time on object files that are the result of the same compilation in a different directory. -

CCACHE_NOUNIFY
If you set the environment variable -CCACHE_NOUNIFY then ccache will not use the C/C++ unifier when hashing -the pre-processor output. The unifier is slower than a normal hash, so -setting this environment variable gains a little bit of speed, but it -means that ccache can't take advantage of not recompiling when the -changes to the source code consist of reformatting only. Note that -using CCACHE_NOUNIFY changes the hash, so cached compiles with -CCACHE_NOUNIFY set cannot be used when CCACHE_NOUNIFY is not set and -vice versa. +

CCACHE_UNIFY
If you set the environment variable CCACHE_UNIFY +then ccache will use the C/C++ unifier when hashing the pre-processor +output if -g is not used in the compile. The unifier is slower than a +normal hash, so setting this environment variable loses a little bit +of speed, but it means that ccache can take advantage of not +recompiling when the changes to the source code consist of +reformatting only. Note that using CCACHE_UNIFY changes the hash, so +cached compiles with CCACHE_UNIFY set cannot be used when +CCACHE_UNIFY is not set and vice versa. The reason the unifier is off +by default is that it can give incorrect line number information in +compiler warning messages.

CACHE SIZE MANAGEMENT