This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/1] Add multilib build support for libc target. Libc is build <multilib>-times in seperate sysroot directories. In a last step links are created to reflect the expected multilib structure.


Konrad, All,

I am slowly and not-so-smoothly coming up with a sane situation wrt the
multilib patch, but there are still a few quirks I don't get right.

First, I split the code so it is more manageable. You can check it with:

    hg qclone -p http://crosstool-ng.org/hg/crosstool-ng/ct-ng.multilib  \
                 http://crosstool-ng.org/hg/crosstool-ng                 \
                 ct-ng.multilib
    cd ct-ng.multilib
    hg qpush -a

Note, this is a WIP:
 - the last patch is just testing fixes, and is not applied (it's guarded);
 - the penultimate patch (the last one applied) is not clean yet, and I may
   split it further to ease testing.

Second, I have some difficulties understanding the do_libc_backend_rearrange
function. See below.

On Monday 14 November 2011 11:37:59 Konrad Eisele wrote:
[--SNIP--]
> diff --git a/scripts/build/libc/glibc-eglibc.sh-common b/scripts/build/libc/glibc-eglibc.sh-common
> index 2af3a9a..2c77fbf 100644
> --- a/scripts/build/libc/glibc-eglibc.sh-common
> +++ b/scripts/build/libc/glibc-eglibc.sh-common
[--SNIP--]
> +# installation is done into ${CT_SYSROOT_DIR}/${dir}. The multilib prefix has to be included
> +# to reflect the runtime setting.
> +do_libc_backend_rearrange() {
> +    local libc_mode
> +    
> +    while [ $# -ne 0 ]; do
> +        eval "${1// /\\ }"
> +        shift
> +    done
> +    
> +    if [ "${libc_mode}" = "final" ]; then
> +        cross_cc=$(CT_Which "${CT_TARGET}-gcc")
> +        for i in `${cross_cc} --print-multi-lib 2>/dev/null`; do

Can you elaborate what you are trying to achieve with this big loop?
I mean, I can read the code, and I could probably end up making it work,
but could you explain in human-readable form the idea behind this code?

From what I see it does absolutely nothing, because ...

> +           dir="${i%%;*}"
> +          bdir="$(echo ${dir} | ${sed} -r -e 's:/:\\\\/:g')"
> +           if [ "${dir}" != "." ]; then 
> +               flags="$(echo $i | ${sed} -r -e 's/^[^;]*;//' -e 's/@/ -/g')";
> +               CT_DoStep DEBUG "Fixing up multilib location ${CT_SYSROOT_DIR}/${dir}/lib to ${CT_SYSROOT_DIR}/lib/${dir}"
> +               mkdir -p ${CT_SYSROOT_DIR}/lib/${dir}
> +               mkdir -p ${CT_SYSROOT_DIR}/usr/lib/${dir}
> +
> +               # recreate the symbolic links for multilib 
> +               for f in $(find ${CT_SYSROOT_DIR}/usr/lib/${dir}/ -type l -maxdepth 1); do

... of the 'find' here, that scans two newly-created directories (just
above), so they are empty.

Did you mean to scan "${dir}/usr/lib" and not "usr/lib/${dir}" ?

And what about "${dir}/lib" ?

Besides, the options ordering to the 'find' command is wrong, and 'find'
complains loudly. No problem, fixed here.

> +                   fn=`basename $f`
> +                   ln=`readlink $f`
> +                   ln=`basename $ln`
> +		   # go toward root. Count the numer of "/" and asseble a "../.." prefix 
> +                   pre=$( echo ${dir} | awk '{r="";
> +		       c=split($0,b,"/");
> +		       for(i=0;i<c;i++){
> +		           if(i!=0){r=r "/";}
> +			   r=r "..";
> +		       };
> +		       printf("%s",r);
> +		   }')
> +		   CT_Pushd "${CT_SYSROOT_DIR}/usr/lib/${dir}/"
> +                   ln -sf ../../${pre}/lib/${dir}/$ln $fn
> +		   CT_Popd
> +               done
> +
> +               # rewrite the library multiplexers
> +               for l in libc libpthread libgcc_s; do
> +                   for d in lib/${dir} usr/lib/${dir}; do
> +                       if [ -f "${CT_SYSROOT_DIR}/${d}/${l}.so" -a ! -L ${CT_SYSROOT_DIR}/${d}/${l}.so ]; then
> +                           if [ ! -f "${CT_SYSROOT_DIR}/${d}/${l}.so_ori_i" ]; then
> +                               cp ${CT_SYSROOT_DIR}/${d}/${l}.so ${CT_SYSROOT_DIR}/${d}/${l}.so_ori_i
> +                               cat ${CT_SYSROOT_DIR}/${d}/${l}.so_ori_i | ${sed} -r -e "s/\/lib\/$l/\/lib\/$bdir\/$l/g" > ${CT_SYSROOT_DIR}/${d}/${l}.so

With this sed expression, you are not rewriting the dynamic linker path,
which means a multilib variant still uses the default "ld.so".

I think the following sed-expr does the trick (and does not require
the '/' mangling done above):
    "s:/lib/:/lib/${dir}/:g;"

(mangling ':' in ${dir} is not needed, the dirname can not contain a ':',
as ':' is the multilib separator in "gcc -print-multi-lib").

> +			   else
> +			       CT_DoLog WARN "${CT_SYSROOT_DIR}/${d}/${l}.so has already been patched, skipping"
> +                           fi
> +                       fi
> +                   done
> +               done
> +               CT_EndStep
> +           fi
> +        done;

In the end, it leaves everything in "sysroot/${dir}".
It would make much more sense to carefully move the libs in their correct
place, that is:
 - move everything from "sysroot/${dir}/lib"     -> "sysroot/lib/${dir}"
                    and "sysroot/${dir}/usr/lib" -> "sysroot/usr/lib/${dir}"
 - get rid of "sysroot/${dir}" alltogether

That's because gcc will search for things in "sysroot/{usr/,}lib/${dir}/",
not in "sysroot/${dir}/{usr/,}lib/"

Of course, we can go with the symlinks first; once that works, we can look
into doing the move and clean-up.

[--SNIP--]
>      case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
> -        y,) extra_config+=("--with-fp");;
> +        y,) # if it is a <multilib> build then check if -msoft-float is given
> +	    if [ "x`expr "${extra_flags}" : '.*-msoft-float.*'`" != "x0" ]; then
> +	    	extra_config+=("--with-fp=no");
> +	    else
> +	    	extra_config+=("--with-fp");
> +	    fi
> +	    ;;
>          ,y) extra_config+=("--without-fp");;
>      esac

Floats are not the only thing we have to account for. For example, some
archs can define big/little multilib. And most probably other stuff
as well...

Well... Time for some rejoicing !
Merry X-Mas to All, and a Happy New Year! Cheers !

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]