]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
added CCACHE_NOUNIFY option
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Apr 2002 00:23:31 +0000 (02:23 +0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 1 Apr 2002 00:23:31 +0000 (02:23 +0200)
Makefile.in
ccache.1
ccache.c
ccache.h
ccache.yo
unify.c

index a26b4c7378ee336185af15b5d61ce8bad2f7ed4a..1e911e0cf85c76782996e5c29f78aa6ddfde0063 100644 (file)
@@ -1,4 +1,3 @@
-
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 bindir=@bindir@
@@ -12,13 +11,18 @@ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
        cleanup.o snprintf.o unify.o
 HEADERS = ccache.h mdfour.h
 
-all: ccache ccache.1
+all: ccache
+
+docs: ccache.1 web/ccache-man.html
 
 ccache: $(OBJS) $(HEADERS)
        $(CC) $(CFLAGS) -o $@ $(OBJS)
 
 ccache.1: ccache.yo
        yodl2man -o ccache.1 ccache.yo
+
+web/ccache-man.html: ccache.yo
+       mkdir -p man
        yodl2html -o web/ccache-man.html ccache.yo
 
 install:
index d4a78360f5fc5ae8a2a521698360d839d94b108a..4a404870ccc4806f1b77448a2125427a6072b28d 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -134,6 +134,14 @@ If you set the environment variable
 CCACHE_DISABLE then ccache will just call the real compiler,
 bypassing the cache completely\&.
 .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\&.
+.IP 
 .PP 
 .SH "CACHE SIZE MANAGEMENT" 
 .PP 
index e7dc5e8c5730b6d67ce15ac387796bf13031015d..cdc5e8d264ebb72088e3eb6e46d5960fe55f1b7d 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -108,40 +108,6 @@ static void to_cache(ARGS *args)
        free(path_stderr);
 }
 
-
-/* hash a file that consists of preprocessor output, but remove any line 
-   number information from the hash
-*/
-static void stabs_hash(const char *fname)
-{
-       int fd;
-       struct stat st; 
-       char *map;
-
-       fd = open(fname, O_RDONLY);
-       if (fd == -1 || fstat(fd, &st) != 0) {
-               cc_log("Failed to open preprocessor output %s\n", fname);
-               stats_update(STATS_PREPROCESSOR);
-               failed();
-       }
-
-       /* we use mmap() to make it easy to handle arbitrarily long
-           lines in preprocessor output. I have seen lines of over
-           100k in length, so this is well worth it */
-       map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
-       if (map == (char *)-1) {
-               cc_log("Failed to mmap %s\n", fname);
-               failed();
-       }
-       close(fd);
-
-       /* pass it through the unifier */
-       unify(map, st.st_size);
-
-       munmap(map, st.st_size);
-}
-
-
 /* find the hash for a command. The hash includes all argument lists,
    plus the output from running the compiler with -E */
 static void find_hash(ARGS *args)
@@ -212,10 +178,12 @@ static void find_hash(ARGS *args)
           information. Otherwise we can discard line number info, which makes
           us less sensitive to reformatting changes 
        */
-       if (found_debug) {
+       if (found_debug || getenv("CCACHE_NOUNIFY")) {
                hash_file(path_stdout);
        } else {
-               stabs_hash(path_stdout);
+               if (unify_hash(path_stdout) != 0) {
+                       failed();
+               }
        }
        hash_file(path_stderr);
 
index 9166f95d20f18afbfd5a0892241acd123591e367..582756dd8b75aa1f3c7f06e043de3d05dcef8c57 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -88,7 +88,8 @@ void stats_set_limits(long maxfiles, long maxsize);
 size_t value_units(const char *s);
 void stats_set_sizes(const char *dir, size_t num_files, size_t total_size);
 
-void unify(unsigned char *p, size_t size);
+int unify_hash(const char *fname);
+
 
 
 void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize);
index d26a0f0909e3cf176e340a92b4362f2b02caa35a..38a80db6ce51b589473fa6024e9cb105cc999679 100644 (file)
--- a/ccache.yo
+++ b/ccache.yo
@@ -114,6 +114,13 @@ dit(bf(CCACHE_DISABLE)) If you set the environment variable
 CCACHE_DISABLE then ccache will just call the real compiler,
 bypassing the cache completely.
 
+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.
+
 enddit()
 
 manpagesection(CACHE SIZE MANAGEMENT)
diff --git a/unify.c b/unify.c
index 6e19bc8993a1586a672ab5c1ab237053dcdafaeb..884237286b69cb48a127caa09673007c38316c52 100644 (file)
--- a/unify.c
+++ b/unify.c
@@ -106,7 +106,7 @@ static void pushchar(unsigned char c)
 }
 
 /* hash some C/C++ code after unifying */
-void unify(unsigned char *p, size_t size)
+static void unify(unsigned char *p, size_t size)
 {
        size_t ofs;
        unsigned char q;
@@ -220,3 +220,38 @@ void unify(unsigned char *p, size_t size)
        pushchar(0);
 }
 
+
+/* hash a file that consists of preprocessor output, but remove any line 
+   number information from the hash
+*/
+int unify_hash(const char *fname)
+{
+       int fd;
+       struct stat st; 
+       char *map;
+
+       fd = open(fname, O_RDONLY);
+       if (fd == -1 || fstat(fd, &st) != 0) {
+               cc_log("Failed to open preprocessor output %s\n", fname);
+               stats_update(STATS_PREPROCESSOR);
+               return -1;
+       }
+
+       /* we use mmap() to make it easy to handle arbitrarily long
+           lines in preprocessor output. I have seen lines of over
+           100k in length, so this is well worth it */
+       map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+       if (map == (char *)-1) {
+               cc_log("Failed to mmap %s\n", fname);
+               return -1;
+       }
+       close(fd);
+
+       /* pass it through the unifier */
+       unify(map, st.st_size);
+
+       munmap(map, st.st_size);
+
+       return 0;
+}
+