Re: [ccache] -Bprefix compiler option - resulting in cache miss
On 11 September 2015 at 12:02, vkrwrote: > 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, _cpp, _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 ___ ccache mailing list ccache@lists.samba.org https://lists.samba.org/mailman/listinfo/ccache
[ccache] -Bprefix compiler option - resulting in cache miss
Hello, 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. Example, if my compilation command is: CCACHE_BASEDIR=$PWD ccache gcc -c hello.c -o hello.o -B$PWD/linkfarm/sysroot-x86_64_cge7/usr/lib64/4.7.0/ then, from what I understand, ccache is considering this argument -B$PWD/linkfarm/sysroot-x86_64_cge7/usr/lib64/4.7.0/ as well, while creating the basic-hash for direct cache lookup, but without rewriting it into its relative path based on CCACHE_BASEDIR setting. Thus, the hash so generated is for the absolute path of this workspace, and cannot be reused from another build sandbox. I verified that the changes done in the fork https://github.com/venkrao/ccache-1/commit/59e5244dd79b0fc7df682c8f3c05b778a3d00f91 fixes the problem. To verify that -Bprefix is also put into the hash, with its absolute path, I put a debug statement on the line https://github.com/venkrao/ccache-1/blob/59e5244dd79b0fc7df682c8f3c05b778a3d00f91/ccache.c#L1594 Please help to verify my understanding and the fix. Thanks, Venkat. ___ ccache mailing list ccache@lists.samba.org https://lists.samba.org/mailman/listinfo/ccache