From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31967 invoked by alias); 24 Dec 2011 21:10:46 -0000 Received: (qmail 31957 invoked by uid 22791); 24 Dec 2011 21:10:45 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail175c2.megamailservers.com (HELO mail175c2.megamailservers.com) (69.49.111.75) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Dec 2011 21:10:26 +0000 X-Authenticated-User: konrad.gaisler.com Received: from [192.168.0.100] (c-83-233-128-200.cust.bredband2.com [83.233.128.200]) (authenticated bits=0) by mail175c2.megamailservers.com (8.13.6/8.13.1) with ESMTP id pBOLA3SW020276; Sat, 24 Dec 2011 16:10:04 -0500 Message-ID: <4EF6400F.8060400@gaisler.com> Date: Sat, 24 Dec 2011 21:10:00 -0000 From: "konrad.gaisler" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: "Yann E. MORIN" CC: 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. References: <1321267079-14623-1-git-send-email-konrad@gaisler.com> <201112240022.18409.yann.morin.1998@anciens.enib.fr> In-Reply-To: <201112240022.18409.yann.morin.1998@anciens.enib.fr> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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/msg00078.txt.bz2 >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" ? Is it possible that I missed something here? I think the first patch I sent included this lines: do_libc_start_files() { cross_cc=$(CT_Which "${CT_TARGET}-gcc") if [ "${CT_CC_MULTILIB}" = "y" ]; then for i in `${cross_cc} --print-multi-lib 2>/dev/null`; do dir=`echo $i | sed -e 's/;.*$//'`; if [ "${dir}" = "." ]; then true; else if [ "${CT_USE_SYSROOT}" = "y" ]; then # prepare installation redirects mkdir -p ${CT_SYSROOT_DIR}/${dir}/usr mkdir -p ${CT_SYSROOT_DIR}/lib/${dir} mkdir -p ${CT_SYSROOT_DIR}/usr/lib/${dir} ln -sf ${CT_SYSROOT_DIR}/usr/lib/${dir} ${CT_SYSROOT_DIR}/${dir}/usr/lib ln -sf ${CT_SYSROOT_DIR}/lib/${dir} ${CT_SYSROOT_DIR}/${dir}/lib fi flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; CT_DoStep INFO "Installing C library start files multilibbed. Flags: ${flags} Dir: ${dir}" do_single_libc_start_files "/${dir}" "${flags}" CT_EndStep fi done; fi do_single_libc_start_files } These symlinks that are installed before the glibc installs make that ${CT_SYSROOT_DIR}/${dir}/usr/lib end up in ${CT_SYSROOT_DIR}/usr/lib/${dir} and ${CT_SYSROOT_DIR}/${dir}/lib end up in ${CT_SYSROOT_DIR}/lib/${dir} The point here is that glibc's install process adds the /lib at the end, however the multilib structure must have /lib before: /lib/. Adding these symlinks before makes the libraries end up in the right place. The "rearrange" stage then fixes up the wrong paths. Hope that makes it more clear. The whole thing might have to be rewritten, I think you might come up with a solution that is easier. > > 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> + 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". You might be right. My particular toolchain doesnt care as for the ld.so probably doesnt differ. It is also so that in the final running embedded-system, there is only one libc set, that is copied back to /usr/lib. I think buildroot needs a patch to copy the right set of libc though. > > 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/" I'm not an insider to glibc, but maybe there is a option to glibc's configure that create the right multilib structure. Then all the hustle with moving and or creating symbolic links would be unneeded. > > 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 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... Sorry, I dont really know the requirements for other archs, I come up with this because I require for sparc glibc the --with-fp=no. > > Well... Time for some rejoicing ! > Merry X-Mas to All, and a Happy New Year! Cheers ! Merry XMas back. It just has passed. -- Konrad > > Regards, > Yann E. MORIN. > -- For unsubscribe information see http://sourceware.org/lists.html#faq