]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
added CCACHE_READONLY and CCACHE_TEMPDIR options, thanks to a
authorAndrew Tridgell <tridge@samba.org>
Fri, 10 Sep 2004 05:05:14 +0000 (07:05 +0200)
committerAndrew Tridgell <tridge@samba.org>
Fri, 10 Sep 2004 05:05:14 +0000 (07:05 +0200)
suggestion from Jeff Apple <japple@paradise.net.nz>

ccache.1
ccache.c
ccache.yo

index 8ffb5cc299c78e60e5abd554774eed6da67d16c4..daec8ee1ef168ceaa6caf86cc036239a743665b6 100644 (file)
--- a/ccache.1
+++ b/ccache.1
@@ -101,6 +101,7 @@ To install for the second method do something like this:
 
   cp ccache /usr/local/bin/
   ln -s /usr/local/bin/ccache /usr/local/bin/gcc
+  ln -s /usr/local/bin/ccache /usr/local/bin/g++
   ln -s /usr/local/bin/ccache /usr/local/bin/cc
 
 .fi 
@@ -118,7 +119,7 @@ cause "interesting" problems\&.
 When run as a compiler front end ccache usually just takes the same
 command line options as the compiler you are using\&. The only exception
 to this is the option \&'--ccache-skip\&'\&. That option can be used to tell
-ccache that the next option is definately not a input filename, and
+ccache that the next option is definitely not a input filename, and
 should be passed along to the compiler as-is\&. 
 .PP 
 The reason this can be important is that ccache does need to parse the
@@ -142,6 +143,13 @@ the CCACHE_DIR environment variable specifies
 where ccache will keep its cached compiler output\&. The default is
 "$HOME/\&.ccache"\&.
 .IP 
+.IP "\fBCCACHE_TEMPDIR\fP" 
+the CCACHE_TEMPDIR environment variable specifies
+where ccache will put temporary files\&. The default is the same as
+CCACHE_DIR\&. Note that the CCACHE_TEMPDIR path must be on the same
+filesystem as the CCACHE_DIR path, so that renames of files between
+the two directories can work\&.
+.IP 
 .IP "\fBCCACHE_LOGFILE\fP" 
 If you set the CCACHE_LOGFILE environment
 variable then ccache will write some log information on cache hits
@@ -169,6 +177,14 @@ If you set the environment variable
 CCACHE_DISABLE then ccache will just call the real compiler,
 bypassing the cache completely\&.
 .IP 
+.IP "\fBCCACHE_READONLY\fP" 
+the CCACHE_READONLY environment variable
+tells ccache to attempt to use existing cached object files, but not
+to try to add anything new to the cache\&. If you are using this because
+your CCACHE_DIR is read-only, then you may find that you also need to
+set CCACHE_TEMPDIR as otherwise ccache will fail to create the
+temporary files\&.
+.IP 
 .IP "\fBCCACHE_CPP2\fP" 
 If you set the environment variable CCACHE_CPP2
 then ccache will not use the optimisation of avoiding the 2nd call to
@@ -304,11 +320,14 @@ following conditions need to be met:
 .IP o 
 Use the same \fBCCACHE_DIR\fP environment variable setting
 .IP o 
-Make sure that all users have write permission in the entire
-cache directory (and that you trust all users of the shared cache)\&. 
+Set the \fBCCACHE_NOLINK\fP environment variable
 .IP o 
 Make sure everyone sets the CCACHE_UMASK environment variable
-to 002, this ensures that cached files are accessible to everyone\&.
+to 002, this ensures that cached files are accessible to everyone in
+the group\&.
+.IP o 
+Make sure that all users have write permission in the entire
+cache directory (and that you trust all users of the shared cache)\&. 
 .IP o 
 Make sure that the setgid bit is set on all directories in the
 cache\&. This tells the filesystem to inherit group ownership for new
index b0fd9dbbe2ee75a56c4b812e8531eebcdc288c65..ace986d1f239067423573141a5e783e09e37862e 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -26,6 +26,9 @@
 /* the base cache directory */
 char *cache_dir = NULL;
 
+/* the directory for temporary files */
+static char *temp_dir = NULL;
+
 /* the debug logfile name, if set */
 char *cache_logfile = NULL;
 
@@ -155,9 +158,9 @@ static void to_cache(ARGS *args)
        struct stat st1, st2;
        int status;
 
-       x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", cache_dir, tmp_string());
-       x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", cache_dir, tmp_string());
-       x_asprintf(&tmp_hashname, "%s/tmp.hash.%s.o", cache_dir, tmp_string());
+       x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string());
+       x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string());
+       x_asprintf(&tmp_hashname, "%s/tmp.hash.%s.o", temp_dir, tmp_string());
 
        args_add(args, "-o");
        args_add(args, tmp_hashname);
@@ -347,10 +350,10 @@ static void find_hash(ARGS *args)
        }
 
        /* now the run */
-       x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", cache_dir,
+       x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir,
                   input_base, tmp_string(), 
                   i_extension);
-       x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", cache_dir, tmp_string());
+       x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
 
        if (!direct_i_file) {
                /* run cpp on the input file to obtain the .i */
@@ -845,6 +848,11 @@ static void ccache(int argc, char *argv[])
 
        /* if we can return from cache at this point then do */
        from_cache(1);
+
+       if (getenv("CCACHE_READONLY")) {
+               cc_log("read-only set - doing real compile\n");
+               failed();
+       }
        
        /* run real compiler, sending output to cache */
        to_cache(stripped_args);
@@ -971,6 +979,11 @@ int main(int argc, char *argv[])
                x_asprintf(&cache_dir, "%s/.ccache", get_home_directory());
        }
 
+       temp_dir = getenv("CCACHE_TEMPDIR");
+       if (!temp_dir) {
+               temp_dir = cache_dir;
+       }
+
        cache_logfile = getenv("CCACHE_LOGFILE");
 
        setup_uncached_err();
index 8c152754dc57b07b4b0e1d913a46295fc80728b3..12e45a6fb0a3f5b0bd6fda96af5aba7f1058c3b9 100644 (file)
--- a/ccache.yo
+++ b/ccache.yo
@@ -125,6 +125,12 @@ dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies
 where ccache will keep its cached compiler output. The default is
 "$HOME/.ccache".
 
+dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies
+where ccache will put temporary files. The default is the same as
+CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same
+filesystem as the CCACHE_DIR path, so that renames of files between
+the two directories can work.
+
 dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment
 variable then ccache will write some log information on cache hits
 and misses in that file. This is useful for tracking down problems.
@@ -147,6 +153,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_READONLY)) the CCACHE_READONLY environment variable
+tells ccache to attempt to use existing cached object files, but not
+to try to add anything new to the cache. If you are using this because
+your CCACHE_DIR is read-only, then you may find that you also need to
+set CCACHE_TEMPDIR as otherwise ccache will fail to create the
+temporary files.
+
 dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2
 then ccache will not use the optimisation of avoiding the 2nd call to
 the pre-processor by compiling the pre-processed output that was used