From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16962 invoked by alias); 23 Dec 2011 23:22:40 -0000 Received: (qmail 16954 invoked by uid 22791); 23 Dec 2011 23:22:38 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_QC,TW_QP X-Spam-Check-By: sourceware.org Received: from smtp10.smtpout.orange.fr (HELO smtp.smtpout.orange.fr) (80.12.242.132) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Dec 2011 23:22:22 +0000 Received: from treguer.localnet ([90.32.2.129]) by mwinf5d19 with ME id CnNK1i00D2n0NGy03nNK1B; Sat, 24 Dec 2011 00:22:20 +0100 From: "Yann E. MORIN" To: crossgcc@sourceware.org Subject: Re: [PATCH 1/1] Add multilib build support for libc target. Libc is build -times in seperate sysroot directories. In a last step links are created to reflect the expected multilib structure. Date: Fri, 23 Dec 2011 23:22:00 -0000 User-Agent: KMail/1.13.5 (Linux/3.1.6-treguer; KDE/4.4.5; x86_64; ; ) Cc: Konrad Eisele References: <1321267079-14623-1-git-send-email-konrad@gaisler.com> In-Reply-To: <1321267079-14623-1-git-send-email-konrad@gaisler.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <201112240022.18409.yann.morin.1998@anciens.enib.fr> Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00076.txt.bz2 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/li= bc/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 prefi= x has to be included > +# to reflect the runtime setting. > +do_libc_backend_rearrange() { > + local libc_mode > +=20=20=20=20 > + while [ $# -ne 0 ]; do > + eval "${1// /\\ }" > + shift > + done > +=20=20=20=20 > + if [ "${libc_mode}" =3D "final" ]; then > + cross_cc=3D$(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? =46rom what I see it does absolutely nothing, because ... > + dir=3D"${i%%;*}" > + bdir=3D"$(echo ${dir} | ${sed} -r -e 's:/:\\\\/:g')" > + if [ "${dir}" !=3D "." ]; then=20 > + flags=3D"$(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=20 > + 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=3D`basename $f` > + ln=3D`readlink $f` > + ln=3D`basename $ln` > + # go toward root. Count the numer of "/" and asseble a "../.." pref= ix=20 > + pre=3D$( echo ${dir} | awk '{r=3D""; > + c=3Dsplit($0,b,"/"); > + for(i=3D0;i + if(i!=3D0){r=3Dr "/";} > + r=3Dr ".."; > + }; > + 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_SY= SROOT_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+=3D("--with-fp");; > + y,) # if it is a build then check if -msoft-float is = given > + if [ "x`expr "${extra_flags}" : '.*-msoft-float.*'`" !=3D "x0" ]; t= hen > + extra_config+=3D("--with-fp=3Dno"); > + else > + extra_config+=3D("--with-fp"); > + fi > + ;; > ,y) extra_config+=3D("--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. --=20 .-----------------.--------------------.------------------.----------------= ----. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspira= cy: | | +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 conspirac= y. | '------------------------------^-------^------------------^----------------= ----' -- For unsubscribe information see http://sourceware.org/lists.html#faq