summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch b/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch
new file mode 100644
index 0000000000..3544f61a74
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch
@@ -0,0 +1,62 @@
1Relative paths don't work with -fdebug-prefix-map and friends. This
2can lead to paths which the user wanted to be remapped being missed.
3Setting -fdebug-prefix-map to work with a relative path isn't practical
4either.
5
6Instead, call gcc's realpath function on the incomming path name before
7comparing it with the remapping. This means other issues like symlinks
8are also accounted for and leads to a more consistent remapping experience.
9
10Upstream-Status: Pending [need to see if gcc developers would accept this]
11Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
12
13
14Index: gcc-12.1.0/gcc/file-prefix-map.cc
15===================================================================
16--- gcc-12.1.0.orig/gcc/file-prefix-map.cc
17+++ gcc-12.1.0/gcc/file-prefix-map.cc
18@@ -70,19 +70,28 @@ remap_filename (file_prefix_map *maps, c
19 file_prefix_map *map;
20 char *s;
21 const char *name;
22+ char *realname;
23 size_t name_len;
24
25+ if (lbasename (filename) == filename)
26+ return filename;
27+
28+ realname = lrealpath (filename);
29+
30 for (map = maps; map; map = map->next)
31- if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
32+ if (filename_ncmp (realname, map->old_prefix, map->old_len) == 0)
33 break;
34- if (!map)
35+ if (!map) {
36+ free (realname);
37 return filename;
38- name = filename + map->old_len;
39+ }
40+ name = realname + map->old_len;
41 name_len = strlen (name) + 1;
42
43 s = (char *) ggc_alloc_atomic (name_len + map->new_len);
44 memcpy (s, map->new_prefix, map->new_len);
45 memcpy (s + map->new_len, name, name_len);
46+ free (realname);
47 return s;
48 }
49
50Index: gcc-12.1.0/libcpp/macro.cc
51===================================================================
52--- gcc-12.1.0.orig/libcpp/macro.cc
53+++ gcc-12.1.0/libcpp/macro.cc
54@@ -563,7 +563,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi
55 if (!name)
56 abort ();
57 }
58- if (pfile->cb.remap_filename)
59+ if (pfile->cb.remap_filename && !pfile->state.in_directive)
60 name = pfile->cb.remap_filename (name);
61 len = strlen (name);
62 buf = _cpp_unaligned_alloc (pfile, len * 2 + 3);