Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 1 | From dab4db14e319f3239a2b4c7d1fbf2971936e27ba Mon Sep 17 00:00:00 2001 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 7 Dec 2015 23:41:45 +0000 |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 4 | Subject: [PATCH 26/36] Search target sysroot gcc version specific dirs with |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 5 | multilib. |
| 6 | |
| 7 | We install the gcc libraries (such as crtbegin.p) into |
| 8 | <sysroot><libdir>/<target-sys>/5.2.0/ |
| 9 | which is a default search path for GCC (aka multi_suffix in the |
| 10 | code below). <target-sys> is 'machine' in gcc's terminology. We use |
| 11 | these directories so that multiple gcc versions could in theory |
| 12 | co-exist on target. |
| 13 | |
| 14 | We only want to build one gcc-cross-canadian per arch and have this work |
| 15 | for all multilibs. <target-sys> can be handled by mapping the multilib |
| 16 | <target-sys> to the one used by gcc-cross-canadian, e.g. |
| 17 | mips64-polkmllib32-linux |
| 18 | is symlinked to by mips64-poky-linux. |
| 19 | |
| 20 | The default gcc search path in the target sysroot for a "lib64" mutlilib |
| 21 | is: |
| 22 | |
| 23 | <sysroot>/lib32/mips64-poky-linux/5.2.0/ |
| 24 | <sysroot>/lib32/../lib64/ |
| 25 | <sysroot>/usr/lib32/mips64-poky-linux/5.2.0/ |
| 26 | <sysroot>/usr/lib32/../lib64/ |
| 27 | <sysroot>/lib32/ |
| 28 | <sysroot>/usr/lib32/ |
| 29 | |
| 30 | which means that the lib32 crtbegin.o will be found and the lib64 ones |
| 31 | will not which leads to compiler failures. |
| 32 | |
| 33 | This patch injects a multilib version of that path first so the lib64 |
| 34 | binaries can be found first. With this change the search path becomes: |
| 35 | |
| 36 | <sysroot>/lib32/../lib64/mips64-poky-linux/5.2.0/ |
| 37 | <sysroot>/lib32/mips64-poky-linux/5.2.0/ |
| 38 | <sysroot>/lib32/../lib64/ |
| 39 | <sysroot>/usr/lib32/../lib64/mips64-poky-linux/5.2.0/ |
| 40 | <sysroot>/usr/lib32/mips64-poky-linux/5.2.0/ |
| 41 | <sysroot>/usr/lib32/../lib64/ |
| 42 | <sysroot>/lib32/ |
| 43 | <sysroot>/usr/lib32/ |
| 44 | |
| 45 | Upstream-Status: Pending |
| 46 | RP 2015/7/31 |
| 47 | |
| 48 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 49 | --- |
| 50 | gcc/gcc.c | 29 ++++++++++++++++++++++++++++- |
| 51 | 1 file changed, 28 insertions(+), 1 deletion(-) |
| 52 | |
| 53 | diff --git a/gcc/gcc.c b/gcc/gcc.c |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 54 | index db0e2934038..1c21d1b08eb 100644 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 55 | --- a/gcc/gcc.c |
| 56 | +++ b/gcc/gcc.c |
| 57 | @@ -2610,7 +2610,7 @@ for_each_path (const struct path_prefix *paths, |
| 58 | if (path == NULL) |
| 59 | { |
| 60 | len = paths->max_len + extra_space + 1; |
| 61 | - len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); |
| 62 | + len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); |
| 63 | path = XNEWVEC (char, len); |
| 64 | } |
| 65 | |
| 66 | @@ -2622,6 +2622,33 @@ for_each_path (const struct path_prefix *paths, |
| 67 | /* Look first in MACHINE/VERSION subdirectory. */ |
| 68 | if (!skip_multi_dir) |
| 69 | { |
| 70 | + if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) |
| 71 | + { |
| 72 | + const char *this_multi; |
| 73 | + size_t this_multi_len; |
| 74 | + |
| 75 | + if (pl->os_multilib) |
| 76 | + { |
| 77 | + this_multi = multi_os_dir; |
| 78 | + this_multi_len = multi_os_dir_len; |
| 79 | + } |
| 80 | + else |
| 81 | + { |
| 82 | + this_multi = multi_dir; |
| 83 | + this_multi_len = multi_dir_len; |
| 84 | + } |
| 85 | + |
| 86 | + /* Look in multilib MACHINE/VERSION subdirectory first */ |
| 87 | + if (this_multi_len) |
| 88 | + { |
| 89 | + memcpy (path + len, this_multi, this_multi_len + 1); |
| 90 | + memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); |
| 91 | + ret = callback (path, callback_info); |
| 92 | + if (ret) |
| 93 | + break; |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | memcpy (path + len, multi_suffix, suffix_len + 1); |
| 98 | ret = callback (path, callback_info); |
| 99 | if (ret) |
| 100 | -- |
Brad Bishop | c68388fc | 2019-08-26 01:33:31 -0400 | [diff] [blame] | 101 | 2.22.1 |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 102 | |