[PATCH] scripts/glibc-eglibc.sh-common: broken symlinks created for nested multilib

David Holsgrove david.holsgrove@xilinx.com
Fri Sep 21 04:42:00 GMT 2012


# HG changeset patch
# User David Holsgrove <david.holsgrove@xilinx.com>
# Date 1348202094 -36000
# Node ID 886f1bbadce3c2a5ea07a4a46ce140a5a04dc555
# Parent  d9ae5974b0bd4f111c00b38a4edd6656bd1f0226
scripts/glibc-eglibc.sh-common: broken symlinks created for nested multilib
dirs

glibc-eglibc.sh-common prepares a number of symlinks for use in building C
Library, which is iterated through for each multilib combo, however there is a
hardcoded number of backsteps in the symlink command which assumes the multi_dir
is only 1 directory deep.

This means we are creating broken symlinks for nested multilib dirs, eg;

  gcc configured with these multilibs (besides the default):
  -mxl-barrel-shift  -->  bs/
  -mxl-barrel-shift -mno-xl-soft-mul  -->  bs/m/
  -mxl-barrel-shift -mno-xl-soft-mul -mxl-multiply-high  -->  bs/m/mh/

  multi_dir=bs;      ln -sf "../lib/bs" "bs/lib"           <- Ok
  multi_dir=bs/m;    ln -sf "../lib/bs/m" "bs/m/lib"       <- Broken
  multi_dir=bs/m/mh; ln -sf "../lib/bs/m/mh" "bs/m/mh/lib" <- Broken

In the Final C Library step, we perform a "Fixing up multilib location" stage,
which in each loop removes its temporary multi_dir - a problem with nested
multilib dirs, as the first loop may be for 'bs' say, which will remove the
'bs' directory, and the nested dirs for bs/m, bs/m/mh along with it, before
they have gone through their own do_libc_backend_once iteration.

The solution I propose is similar to how the build-libc-${libc_mode}
directories are created - replacing '/' with '_' and having a flat structure
for these temp multi_dirs

Signed-off-by: "David Holsgrove" <david.holsgrove@xilinx.com>

diff -r d9ae5974b0bd -r 886f1bbadce3 scripts/build/libc/glibc-eglibc.sh-common
--- a/scripts/build/libc/glibc-eglibc.sh-common	Thu Sep 20 15:21:40 2012 +1000
+++ b/scripts/build/libc/glibc-eglibc.sh-common	Fri Sep 21 14:34:54 2012 +1000
@@ -77,6 +77,7 @@
     local multi_dir
     local multi_flags
     local extra_dir
+    local flat_dir
     local libc_headers libc_startfiles libc_full
     local hdr
     local arg
@@ -112,10 +113,11 @@
             extra_flags="$( echo "${multilib#*;}"       \
                             |${sed} -r -e 's/@/ -/g;'   \
                           )"
-            extra_dir="/${multi_dir}"
+            flat_dir="libc_${multi_dir//\//_}"
+            extra_dir="/${flat_dir}"
 
-            # glibc install its files in ${extra_dir}/{usr/,}lib
-            # while gcc expects them in {,usr/}lib/${extra_dir}.
+            # glibc install its files in /${flat_dir}/{usr/,}lib
+            # while gcc expects them in {,usr/}lib/${multi_dir}.
             # Prepare some symlinks so glibc installs in fact in
             # the proper place
             # We do it in the start-files step, so it is not needed
@@ -125,10 +127,10 @@
                 CT_Pushd "${CT_SYSROOT_DIR}"
                 CT_DoExecLog ALL mkdir -p "lib/${multi_dir}"        \
                                           "usr/lib/${multi_dir}"    \
-                                          "${multi_dir}"            \
-                                          "${multi_dir}/usr"
-                CT_DoExecLog ALL ln -sf "../lib/${multi_dir}" "${multi_dir}/lib"
-                CT_DoExecLog ALL ln -sf "../../usr/lib/${multi_dir}" "${multi_dir}/usr/lib"
+                                          "${flat_dir}"            \
+                                          "${flat_dir}/usr"
+                CT_DoExecLog ALL ln -sf "../lib/${multi_dir}" "${flat_dir}/lib"
+                CT_DoExecLog ALL ln -sf "../../usr/lib/${multi_dir}" "${flat_dir}/usr/lib"
                 CT_Popd
             fi
             libc_headers=
@@ -164,8 +166,8 @@
                         fi
                     done
                 done
-                # Remove the multi_dir now it is no longer useful
-                CT_DoExecLog DEBUG rm -rf "${CT_SYSROOT_DIR}/${multi_dir}"
+                # Remove the flat_dir now it is no longer useful
+                CT_DoExecLog DEBUG rm -rf "${CT_SYSROOT_DIR}/${flat_dir}"
             fi # libc_mode == final
 
             CT_EndStep

--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list