diff mbox

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

Message ID 886f1bbadce3c2a5ea07.1348202558@localhost.localdomain
State New
Headers show

Commit Message

David Holsgrove Sept. 21, 2012, 4:42 a.m. UTC
# 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>


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

Comments

Yann E. MORIN Sept. 25, 2012, 9:55 p.m. UTC | #1
David, All,

On Friday 21 September 2012 06:42:38 David Holsgrove wrote:
> # 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

libc/glibc-eglibc: fix symlinks 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

In theory, I have nothing serious against your patch. Except I don't know
how to test it. Care to share a defconfig (ct-ng defconfig), please?

Regards,
Yann E. MORIN.
Yann E. MORIN Oct. 23, 2012, 5:08 p.m. UTC | #2
David, All,

As you pointed me to this mesage in the "custom location" thread:

On Tuesday 25 September 2012 Yann E. MORIN wrote:
> On Friday 21 September 2012 06:42:38 David Holsgrove wrote:
> > # 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
[--SNIP--]
> In theory, I have nothing serious against your patch. Except I don't know
> how to test it. Care to share a defconfig (ct-ng defconfig), please?

Care to expand on hos to test it, please? ;-)

Regards,
Yann E. MORIN.
diff mbox

Patch

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