From: Andrew Tridgell Date: Wed, 3 Apr 2002 14:45:51 +0000 (+0200) Subject: - added CCACHE_NLEVELS variable X-Git-Tag: v1.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdcb027913dcbc2df84edcfa0496d8325232faca;p=thirdparty%2Fccache.git - added CCACHE_NLEVELS variable - fixed absolute path hanlding when launching ccache as "ccache /usr/blah/gcc" --- diff --git a/ccache.1 b/ccache.1 index 58ff795a7..eacc9735c 100644 --- a/ccache.1 +++ b/ccache.1 @@ -139,6 +139,11 @@ If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile\&. .IP +.IP "\fBCCACHE_NLEVELS\fP" +The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory\&. The +default is 2\&. The minimum is 1 and the maximum is 8\&. +.IP .IP "\fBCCACHE_NOLINK\fP" If you set the environment variable CCACHE_NOLINK then ccache will not use hard links from the cache diff --git a/ccache.c b/ccache.c index c278ed70f..6f50cac7f 100644 --- a/ccache.c +++ b/ccache.c @@ -39,6 +39,7 @@ static void failed(void) { execv(orig_args->argv[0], orig_args->argv); cc_log("execv returned (%s)!\n", strerror(errno)); + perror(orig_args->argv[0]); exit(1); } @@ -115,11 +116,17 @@ static void find_hash(ARGS *args) { int i; char *path_stdout, *path_stderr; - char *hash_dir1; char *hash_dir; char *s; struct stat st; int status; + int nlevels = 2; + + if ((s = getenv("CCACHE_NLEVELS"))) { + nlevels = atoi(s); + if (nlevels < 1) nlevels = 1; + if (nlevels > 8) nlevels = 8; + } hash_start(); @@ -196,23 +203,27 @@ static void find_hash(ARGS *args) free(path_stdout); free(path_stderr); - /* we use a 2 level subdir for the cache path to reduce the impact + /* we use a N level subdir for the cache path to reduce the impact on filesystems which are slow for large directories */ s = hash_result(); - x_asprintf(&hash_dir1, "%s/%c", cache_dir, s[0]); - x_asprintf(&stats_file, "%s/stats", hash_dir1); - if (create_dir(hash_dir1) != 0) { - cc_log("failed to create %s\n", hash_dir1); - failed(); + x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]); + x_asprintf(&stats_file, "%s/stats", hash_dir); + for (i=1; iargv++; orig_args->argc--; free(base); + if (strchr(argv[1],'/')) { + /* a full path was given */ + return; + } base = basename(argv[1]); } diff --git a/ccache.yo b/ccache.yo index 472fc7e1c..547d0cf45 100644 --- a/ccache.yo +++ b/ccache.yo @@ -118,6 +118,10 @@ dit(bf(CCACHE_NOSTATS)) If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. +dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory. The +default is 2. The minimum is 1 and the maximum is 8. + dit(bf(CCACHE_NOLINK)) If you set the environment variable CCACHE_NOLINK then ccache will not use hard links from the cache directory when creating the compiler output and will do a file copy diff --git a/web/ccache-man.html b/web/ccache-man.html index be2238122..63e46b41f 100644 --- a/web/ccache-man.html +++ b/web/ccache-man.html @@ -116,6 +116,9 @@ bypassing the cache completely.

CCACHE_NOSTATS
If you set the environment variable CCACHE_NOSTATS then ccache will not update the statistics files on each compile. +

CCACHE_NLEVELS
The environment variable CCACHE_NLEVELS allows +you to choose the number of levels of hash in the cache directory. The +default is 2. The minimum is 1 and the maximum is 8.

CCACHE_NOLINK
If you set the environment variable CCACHE_NOLINK then ccache will not use hard links from the cache directory when creating the compiler output and will do a file copy