directory. If set to the empty string (which is the default), no rewriting
is done. See also the discussion under
<<_compiling_in_different_directories,COMPILING IN DIFFERENT DIRECTORIES>>.
+ If using GCC*, you might want to look into the *-fdebug-prefix-map* option
+ for relocating debug info to a common prefix (mapping prefix with old=new).
+
+ * or newer versions of Clang, see: http://reviews.llvm.org/rL250094
*cache_dir* (*CCACHE_DIR*)::
/* is gcc being asked to output coverage? */
static bool generating_coverage;
+/* relocating debuginfo, in the format old=new */
+static char *debug_prefix_map = NULL;
+
/* is gcc being asked to output coverage data (.gcda) at runtime? */
static bool profile_arcs;
/* Possibly hash the current working directory. */
if (conf->hash_dir) {
char *cwd = gnu_getcwd();
+ if (debug_prefix_map) {
+ char *map = debug_prefix_map;
+ char *sep = strchr(map, '=');
+ char *dir, *old, *new;
+ if (sep) {
+ old = x_strndup(map, sep - map);
+ new = x_strdup(sep + 1);
+ cc_log("Relocating debuginfo cwd %s, from %s to %s", cwd, old, new);
+ if (str_startswith(cwd, old)) {
+ dir = format("%s%s", new, cwd + strlen(old));
+ free(cwd);
+ cwd = dir;
+ }
+ free(old);
+ free(new);
+ }
+ }
if (cwd) {
hash_delimiter(hash, "cwd");
hash_string(hash, cwd);
args_add(stripped_args, argv[i]);
continue;
}
+ if (str_startswith(argv[i], "-fdebug-prefix-map=")) {
+ debug_prefix_map = x_strdup(argv[i] + 19);
+ args_add(stripped_args, argv[i]);
+ continue;
+ }
/* Debugging is handled specially, so that we know if we can strip line
* number info. */
free(primary_config_path); primary_config_path = NULL;
free(secondary_config_path); secondary_config_path = NULL;
free(current_working_dir); current_working_dir = NULL;
+ free(debug_prefix_map); debug_prefix_map = NULL;
free(profile_dir); profile_dir = NULL;
free(included_pch_file); included_pch_file = NULL;
args_free(orig_args); orig_args = NULL;