[ccache] Re: [distcc] ccache doesn't handle .i files
eezyy at gmx.net
eezyy at gmx.net
Wed Sep 24 06:44:31 EST 2003
on Mon, 21 Jul 2003 23:52:45 -0700, Martin Pool wrote:
If I run ccache 2.2 on a .i file, it thinks it's not a C/C++ file and
it doesn't cache it.
This could be naively fixed by updating check_extension(), but it
would be far better for ccache to know that it doesn't need to run cpp
on such files. distcc does so.
In particular this means that if ccache is run by distcc or distccd it
will never hit.
This is not a terribly big deal but might be nice to fix.
--
Martin
imho it's a better way to combine ccache and distcc to ccache on the
distcc hosts after distributing, as compiler upgrades are handled
correctly this way.
maybe this will do(I know it's kludgy but to nicely implement it some
redesign of ccache would be needed):
--- ccache/ccache.c 2003-09-23 20:09:54.000000000 +0200
+++ ccache-new/ccache.c 2003-09-23 22:25:49.000000000 +0200
@@ -43,6 +43,12 @@
/* the name of the file containing the cached object code */
static char *hashname;
+/* whether to do pre-processing */
+static int preprocess;
+
+/* the extension of the file before pre-processing */
+static const char *extension;
+
/* the extension of the file after pre-processing */
static const char *i_extension;
@@ -64,19 +70,23 @@
static struct {
char *extension;
char *i_extension;
+ int preprocess;
} extensions[] = {
- {"c", "i"},
- {"C", "ii"},
- {"m", "mi"},
- {"cc", "ii"},
- {"CC", "ii"},
- {"cpp", "ii"},
- {"CPP", "ii"},
- {"cxx", "ii"},
- {"CXX", "ii"},
- {"c++", "ii"},
- {"C++", "ii"},
- {NULL, NULL}};
+ {"c", "i", 1},
+ {"C", "ii", 1},
+ {"m", "mi", 1},
+ {"cc", "ii", 1},
+ {"CC", "ii", 1},
+ {"cpp", "ii", 1},
+ {"CPP", "ii", 1},
+ {"cxx", "ii", 1},
+ {"CXX", "ii", 1},
+ {"c++", "ii", 1},
+ {"C++", "ii", 1},
+ {"i", "i", 0},
+ {"ii", "ii", 0},
+ {"mi", "mi", 0},
+ {NULL, NULL, 0}};
/*
something went badly wrong - just execute the real compiler
@@ -235,6 +245,7 @@
{
int i;
char *path_stdout, *path_stderr;
+ char *command;
char *hash_dir;
char *s;
struct stat st;
@@ -309,11 +320,12 @@
}
}
- /* now the run */
x_asprintf(&path_stdout, "%s/tmp.stdout.%s.%s", cache_dir, tmp_string(),
i_extension);
x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", cache_dir, tmp_string());
+ if (preprocess) {
+ /* now the run */
args_add(args, "-E");
args_add(args, input_file);
status = execute(args->argv, path_stdout, path_stderr);
@@ -327,6 +339,12 @@
failed();
}
+ } else {
+ copy_file(input_file, path_stdout);
+ x_asprintf(&command, "touch %s", path_stderr);
+ system(command);
+ free(command);
+ }
/* if the compilation is with -g then we have to inlcude the whole of the
preprocessor output, which means we are sensitive to line number
information. Otherwise we can discard line number info, which makes
@@ -536,6 +554,8 @@
if (strcmp(p, extensions[i].extension) == 0) {
p = getenv("CCACHE_EXTENSION");
if (p) return p;
+ extension = extensions[i].extension;
+ preprocess = extensions[i].preprocess;
return extensions[i].i_extension;
}
}
More information about the ccache
mailing list