Hi, I am creating dependency files with my gcc compile, with something like: gxx -c -MMD -MF _dep_file.d -o _out_file.o ....
and am using CCACHE_BASEDIR to share the cache across different work boxes. Both _dep_file.d and _out_file.o are absolute paths and start with CCACHE_BASEDIR. Looking at the code, my understanding is that if ccache determines that dependencies are being created it does the following: - If -MF is not specified, ccache add "-MF _out_file.d" to the preprocessor args. - Similarly if -MQ is not specified, it adds "-MQ _out_file.o" to the preprocessor args. These arguments are also used in the hash calculation. I see that ccache does not seem to strip out CCACHE_BASEDIR from them. This seems to be the reason I am not getting any hits in the subsequent compiles in other work spaces. I have appended a patch against ccache version 3.1.7 that fixes this. I would appreciate if it could be reviewed (and hopefully incorporated into ccache). Thanks, Lalit Chhabra ------------------------------------------------------------------------------------ --- ccache-3.1.7/ccache.c 2012-01-08 06:40:55.000000000 -0800 +++ ccache-3.1.7.mod/ccache.c 2012-07-26 18:40:04.268732000 -0700 @@ -1414,7 +1414,6 @@ char *arg; dependency_filename_specified = true; free(output_dep); - args_add(dep_args, argv[i]); if (strlen(argv[i]) == 3) { /* -MF arg */ if (i >= argc - 1) { @@ -1424,13 +1423,14 @@ goto out; } arg = argv[i + 1]; - args_add(dep_args, argv[i + 1]); i++; } else { /* -MFarg */ arg = &argv[i][3]; } output_dep = make_relative_path(x_strdup(arg)); + args_add(dep_args, "-MF"); + args_add(dep_args, output_dep); continue; } if (str_startswith(argv[i], "-MQ") || str_startswith(argv[i], "-MT")) { @@ -1726,11 +1726,13 @@ * Add flags for dependency generation only to the preprocessor command line. */ if (generating_dependencies) { + char *stripped_output_obj; + stripped_output_obj = make_relative_path(x_strdup(output_obj)); if (!dependency_filename_specified) { char *default_depfile_name; char *base_name; - base_name = remove_extension(output_obj); + base_name = remove_extension(stripped_output_obj); default_depfile_name = format("%s.d", base_name); free(base_name); args_add(dep_args, "-MF"); @@ -1740,8 +1742,9 @@ if (!dependency_target_specified) { args_add(dep_args, "-MQ"); - args_add(dep_args, output_obj); + args_add(dep_args, stripped_output_obj); } + free(stripped_output_obj); } if (compile_preprocessed_source_code) { ------------------------------------------------------------------------------------ _______________________________________________ ccache mailing list ccache@lists.samba.org https://lists.samba.org/mailman/listinfo/ccache