diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 17:17:20 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-17 19:57:32 +0100 |
commit | abd30f85c649fa5b0d93ea766cbb8c1806f81bc4 (patch) | |
tree | f6d543feb65ab0e33f9d0bb4f08b68e2fea99376 /meta/recipes-devtools/gcc | |
parent | abbbc8712937fdda93df04b460f8f9e8277f8c21 (diff) | |
download | poky-abd30f85c649fa5b0d93ea766cbb8c1806f81bc4.tar.gz |
gcc: Resolve relative prefix-map filenames
Add a patch to gcc so that relative paths are handled by -fdebug-prefix-map
and friends. In OE we use relative paths in autotools and removing that
creates a lot of issues we'd have to fix. This alternative allows us to
fix the paths within gcc and improve our debug file coverage (and SPDX
manifests) accordingly.
(From OE-Core rev: 591cbe7140f01470b5799bc51e5b23f58bf95ffa)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/gcc')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-12.1.inc | 1 | ||||
-rw-r--r-- | meta/recipes-devtools/gcc/gcc/prefix-map-realpath.patch | 62 |
2 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-12.1.inc b/meta/recipes-devtools/gcc/gcc-12.1.inc index 56678c78be..c42fa3d72f 100644 --- a/meta/recipes-devtools/gcc/gcc-12.1.inc +++ b/meta/recipes-devtools/gcc/gcc-12.1.inc | |||
@@ -65,6 +65,7 @@ SRC_URI = "${BASEURI} \ | |||
65 | file://0025-Move-sched.h-include-ahead-of-user-headers.patch \ | 65 | file://0025-Move-sched.h-include-ahead-of-user-headers.patch \ |
66 | file://0026-rust-recursion-limit.patch \ | 66 | file://0026-rust-recursion-limit.patch \ |
67 | file://0001-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch \ | 67 | file://0001-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch \ |
68 | file://prefix-map-realpath.patch \ | ||
68 | " | 69 | " |
69 | SRC_URI[sha256sum] = "62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b" | 70 | SRC_URI[sha256sum] = "62fd634889f31c02b64af2c468f064b47ad1ca78411c45abe6ac4b5f8dd19c7b" |
70 | 71 | ||
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 @@ | |||
1 | Relative paths don't work with -fdebug-prefix-map and friends. This | ||
2 | can lead to paths which the user wanted to be remapped being missed. | ||
3 | Setting -fdebug-prefix-map to work with a relative path isn't practical | ||
4 | either. | ||
5 | |||
6 | Instead, call gcc's realpath function on the incomming path name before | ||
7 | comparing it with the remapping. This means other issues like symlinks | ||
8 | are also accounted for and leads to a more consistent remapping experience. | ||
9 | |||
10 | Upstream-Status: Pending [need to see if gcc developers would accept this] | ||
11 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> | ||
12 | |||
13 | |||
14 | Index: 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 | |||
50 | Index: 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); | ||