[ccache] -Bprefix compiler option - resulting in cache miss
Joel Rosdahl
joel at rosdahl.net
Sat Sep 19 14:33:19 UTC 2015
On 11 September 2015 at 12:02, vkr <venkatakrishnarao.ks at gmail.com> wrote:
> I believe I found a potential bug with ccache that results in cache-miss if
> -Bprfix compilation option is used, where prefix specifies where to find
> the executables, libraries, include files, and data files of the compiler
> itself. [...]
>
I would rather call it "not yet supported" than a bug. :-) But yes, your
observation is correct.
Please help to verify my understanding and the fix.
Looks good to me. Here's a test case you can use to verify your improvement:
--- a/test/test_argument_processing.c
+++ b/test/test_argument_processing.c
@@ -134,6 +134,28 @@ TEST(sysroot_should_be_rewritten_if_basedir_is_used)
args_free(act_cc);
}
+TEST(B_option_should_be_rewritten_if_basedir_is_used)
+{
+ extern char *current_working_dir;
+ char *arg_string;
+ struct args *orig;
+ struct args *act_cpp = NULL, *act_cc = NULL;
+
+ create_file("foo.c", "");
+ free(conf->base_dir);
+ conf->base_dir = x_strdup("/");
+ current_working_dir = get_cwd();
+ arg_string = format("cc -B%s/foo -c foo.c", current_working_dir);
+ orig = args_init_from_string(arg_string);
+
+ CHECK(cc_process_args(orig, &act_cpp, &act_cc));
+ CHECK_STR_EQ(act_cpp->argv[1], "-B./foo");
+
+ args_free(orig);
+ args_free(act_cpp);
+ args_free(act_cc);
+}
+
TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
{
struct args *orig = args_init_from_string(
-- Joel
More information about the ccache
mailing list