0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch 3.2 KB

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