mirror of
https://github.com/reactos/ccache.git
synced 2024-10-07 09:03:32 +00:00
added CCACHE_NOUNIFY option
This commit is contained in:
parent
5d11689fb7
commit
4867d787f2
@ -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:
|
||||
|
8
ccache.1
8
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
|
||||
|
40
ccache.c
40
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);
|
||||
|
||||
|
3
ccache.h
3
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);
|
||||
|
@ -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)
|
||||
|
37
unify.c
37
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user