From: Chris AtLee Date: Mon, 25 Jul 2011 12:38:01 +0000 (-0400) Subject: Make sure we only handle known -fprofile flags. Rewrite profile X-Git-Tag: v3.2~178^2~4^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91a2954e;p=thirdparty%2Fccache.git Make sure we only handle known -fprofile flags. Rewrite profile directory to use absolute paths on commandline to increase direct / preprocessed hit rate. --- diff --git a/ccache.c b/ccache.c index cad2943cf..21657ad2d 100644 --- a/ccache.c +++ b/ccache.c @@ -1588,22 +1588,50 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args, if (str_startswith(argv[i], "-fprofile-")) { char* arg_profile_dir = strchr(argv[i], '='); + char* arg = x_strdup(argv[i]); if (arg_profile_dir) { + char* option = x_strndup(argv[i], arg_profile_dir - argv[i]); + /* convert to absolute path */ - profile_dir = x_realpath(arg_profile_dir + 1); - cc_log("Setting profile directory to %s", profile_dir); + arg_profile_dir = x_realpath(arg_profile_dir + 1); + + /* We can get a better hit rate by using the + * real path here */ + free(arg); + arg = format("%s=%s", option, profile_dir); + cc_log("Rewriting arg to %s", arg); + free(option); } + if (str_startswith(argv[i], "-fprofile-generate") || str_eq(argv[i], "-fprofile-arcs")) { profile_generate = true; + if (arg_profile_dir) { + profile_dir = arg_profile_dir; + } + cc_log("Setting profile directory to %s", profile_dir); + args_add(stripped_args, arg); + free(arg); + continue; } else if (str_startswith(argv[i], "-fprofile-use") || str_eq(argv[i], "-fbranch-probabilities")) { profile_use = true; - } else { - cc_log("Unsupported profile option: %s", argv[i]); + if (arg_profile_dir) { + profile_dir = arg_profile_dir; + } + cc_log("Setting profile directory to %s", profile_dir); + args_add(stripped_args, arg); + free(arg); + continue; + } else if (str_eq(argv[i], "-fprofile-dir")) { + if (arg_profile_dir) { + profile_dir = arg_profile_dir; + } + cc_log("Setting profile directory to %s", profile_dir); + args_add(stripped_args, arg); + continue; } - args_add(stripped_args, argv[i]); - continue; + cc_log("Unknown profile option: %s", argv[i]); } /*