From c4e40a48fbb5888567c974c0326d8a2cbc2188f0 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 31 Jul 2015 11:26:24 +0100 Subject: gcc: Add patch to handle on target multilibs better On target multilibs did not work properly since gcc-cross-canadian was only searching a limited number of sysroot directories to find multilib target binaries. This adds an extra search path to ensure those binaries are found and our gcc-cross-canadian works everywhere we need it to, e.g. with mips trilib configurations. (From OE-Core rev: b928d92bb9f76c118846d6c495dc57c149368f0f) Signed-off-by: Richard Purdie --- meta/recipes-devtools/gcc/gcc-4.9.inc | 1 + .../0064-handle-target-sysroot-multilib.patch | 88 ++++++++++++++++++++++ meta/recipes-devtools/gcc/gcc-5.2.inc | 1 + .../0041-handle-target-sysroot-multilib.patch | 88 ++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 meta/recipes-devtools/gcc/gcc-4.9/0064-handle-target-sysroot-multilib.patch create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0041-handle-target-sysroot-multilib.patch (limited to 'meta/recipes-devtools/gcc') diff --git a/meta/recipes-devtools/gcc/gcc-4.9.inc b/meta/recipes-devtools/gcc/gcc-4.9.inc index 7a3e4ebd6a..691ba5fbc2 100644 --- a/meta/recipes-devtools/gcc/gcc-4.9.inc +++ b/meta/recipes-devtools/gcc/gcc-4.9.inc @@ -79,6 +79,7 @@ SRC_URI = "\ file://0061-target-gcc-includedir.patch \ file://0062-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \ file://0063-nativesdk-gcc-support.patch \ + file://0064-handle-target-sysroot-multilib.patch \ " SRC_URI[md5sum] = "6f831b4d251872736e8e9cc09746f327" SRC_URI[sha256sum] = "2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e" diff --git a/meta/recipes-devtools/gcc/gcc-4.9/0064-handle-target-sysroot-multilib.patch b/meta/recipes-devtools/gcc/gcc-4.9/0064-handle-target-sysroot-multilib.patch new file mode 100644 index 0000000000..53569847f2 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-4.9/0064-handle-target-sysroot-multilib.patch @@ -0,0 +1,88 @@ +Search target sysroot gcc version specific dirs with multilib. + +We install the gcc libraries (such as crtbegin.p) into +//5.2.0/ +which is a default search path for GCC (aka multi_suffix in the +code below). is 'machine' in gcc's terminology. We use +these directories so that multiple gcc versions could in theory +co-exist on target. + +We only want to build one gcc-cross-canadian per arch and have this work +for all multilibs. can be handled by mapping the multilib + to the one used by gcc-cross-canadian, e.g. mips64-polkmllib32-linux +is symlinked to by mips64-poky-linux. + +The default gcc search path in the target sysroot for a "lib64" mutlilib is: + +/lib32/mips64-poky-linux/5.2.0/ +/lib32/../lib64/ +/usr/lib32/mips64-poky-linux/5.2.0/ +/usr/lib32/../lib64/ +/lib32/ +/usr/lib32/ + +which means that the lib32 crtbegin.o will be found and the lib64 ones +will not which leads to compiler failures. + +This patch injects a multilib version of that path first so the lib64 +binaries can be found first. With this change the search path becomes: + +/lib32/../lib64/mips64-poky-linux/5.2.0/ +/lib32/mips64-poky-linux/5.2.0/ +/lib32/../lib64/ +/usr/lib32/../lib64/mips64-poky-linux/5.2.0/ +/usr/lib32/mips64-poky-linux/5.2.0/ +/usr/lib32/../lib64/ +/lib32/ +/usr/lib32/ + +Upstream-Status: Pending +RP 2015/7/31 + +Index: gcc-5.2.0/gcc/gcc.c +=================================================================== +--- gcc-5.2.0.orig/gcc/gcc.c ++++ gcc-5.2.0/gcc/gcc.c +@@ -2305,7 +2305,7 @@ for_each_path (const struct path_prefix + if (path == NULL) + { + len = paths->max_len + extra_space + 1; +- len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); ++ len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); + path = XNEWVEC (char, len); + } + +@@ -2317,6 +2317,33 @@ for_each_path (const struct path_prefix + /* Look first in MACHINE/VERSION subdirectory. */ + if (!skip_multi_dir) + { ++ if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) ++ { ++ const char *this_multi; ++ size_t this_multi_len; ++ ++ if (pl->os_multilib) ++ { ++ this_multi = multi_os_dir; ++ this_multi_len = multi_os_dir_len; ++ } ++ else ++ { ++ this_multi = multi_dir; ++ this_multi_len = multi_dir_len; ++ } ++ ++ /* Look in multilib MACHINE/VERSION subdirectory first */ ++ if (this_multi_len) ++ { ++ memcpy (path + len, this_multi, this_multi_len + 1); ++ memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); ++ ret = callback (path, callback_info); ++ if (ret) ++ break; ++ } ++ } ++ + memcpy (path + len, multi_suffix, suffix_len + 1); + ret = callback (path, callback_info); + if (ret) diff --git a/meta/recipes-devtools/gcc/gcc-5.2.inc b/meta/recipes-devtools/gcc/gcc-5.2.inc index 1a1ed4ccdc..f691f582d7 100644 --- a/meta/recipes-devtools/gcc/gcc-5.2.inc +++ b/meta/recipes-devtools/gcc/gcc-5.2.inc @@ -72,6 +72,7 @@ SRC_URI = "\ file://0038-fix-g++-sysroot.patch \ file://0039-libcc1-fix-libcc1-s-install-path-and-rpath.patch \ file://0040-nativesdk-gcc-support.patch \ + file://0041-handle-target-sysroot-multilib.patch \ " BACKPORTS = "" diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0041-handle-target-sysroot-multilib.patch b/meta/recipes-devtools/gcc/gcc-5.2/0041-handle-target-sysroot-multilib.patch new file mode 100644 index 0000000000..53569847f2 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-5.2/0041-handle-target-sysroot-multilib.patch @@ -0,0 +1,88 @@ +Search target sysroot gcc version specific dirs with multilib. + +We install the gcc libraries (such as crtbegin.p) into +//5.2.0/ +which is a default search path for GCC (aka multi_suffix in the +code below). is 'machine' in gcc's terminology. We use +these directories so that multiple gcc versions could in theory +co-exist on target. + +We only want to build one gcc-cross-canadian per arch and have this work +for all multilibs. can be handled by mapping the multilib + to the one used by gcc-cross-canadian, e.g. mips64-polkmllib32-linux +is symlinked to by mips64-poky-linux. + +The default gcc search path in the target sysroot for a "lib64" mutlilib is: + +/lib32/mips64-poky-linux/5.2.0/ +/lib32/../lib64/ +/usr/lib32/mips64-poky-linux/5.2.0/ +/usr/lib32/../lib64/ +/lib32/ +/usr/lib32/ + +which means that the lib32 crtbegin.o will be found and the lib64 ones +will not which leads to compiler failures. + +This patch injects a multilib version of that path first so the lib64 +binaries can be found first. With this change the search path becomes: + +/lib32/../lib64/mips64-poky-linux/5.2.0/ +/lib32/mips64-poky-linux/5.2.0/ +/lib32/../lib64/ +/usr/lib32/../lib64/mips64-poky-linux/5.2.0/ +/usr/lib32/mips64-poky-linux/5.2.0/ +/usr/lib32/../lib64/ +/lib32/ +/usr/lib32/ + +Upstream-Status: Pending +RP 2015/7/31 + +Index: gcc-5.2.0/gcc/gcc.c +=================================================================== +--- gcc-5.2.0.orig/gcc/gcc.c ++++ gcc-5.2.0/gcc/gcc.c +@@ -2305,7 +2305,7 @@ for_each_path (const struct path_prefix + if (path == NULL) + { + len = paths->max_len + extra_space + 1; +- len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len); ++ len += MAX ((suffix_len + multi_os_dir_len), multiarch_len); + path = XNEWVEC (char, len); + } + +@@ -2317,6 +2317,33 @@ for_each_path (const struct path_prefix + /* Look first in MACHINE/VERSION subdirectory. */ + if (!skip_multi_dir) + { ++ if (!(pl->os_multilib ? skip_multi_os_dir : skip_multi_dir)) ++ { ++ const char *this_multi; ++ size_t this_multi_len; ++ ++ if (pl->os_multilib) ++ { ++ this_multi = multi_os_dir; ++ this_multi_len = multi_os_dir_len; ++ } ++ else ++ { ++ this_multi = multi_dir; ++ this_multi_len = multi_dir_len; ++ } ++ ++ /* Look in multilib MACHINE/VERSION subdirectory first */ ++ if (this_multi_len) ++ { ++ memcpy (path + len, this_multi, this_multi_len + 1); ++ memcpy (path + len + this_multi_len, multi_suffix, suffix_len + 1); ++ ret = callback (path, callback_info); ++ if (ret) ++ break; ++ } ++ } ++ + memcpy (path + len, multi_suffix, suffix_len + 1); + ret = callback (path, callback_info); + if (ret) -- cgit v1.2.3-54-g00ecf