From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18934 invoked by alias); 14 Nov 2011 10:45:33 -0000 Received: (qmail 18920 invoked by uid 22791); 14 Nov 2011 10:45:31 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail201c2.megamailservers.com (HELO mail201c2.megamailservers.com) (69.49.111.102) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Nov 2011 10:45:16 +0000 X-Authenticated-User: konrad.gaisler.com Received: from localhost.localdomain (gaisler.se [92.33.28.242]) (authenticated bits=0) by mail201c2.megamailservers.com (8.13.6/8.13.1) with ESMTP id pAEAj4Z1020730; Mon, 14 Nov 2011 05:45:09 -0500 From: Konrad Eisele To: crossgcc@sourceware.org Cc: yann.morin.1998@anciens.enib.fr, konrad@gaisler.com Subject: [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: Mon, 14 Nov 2011 10:45:00 -0000 Message-Id: <1321267079-14623-1-git-send-email-konrad@gaisler.com> X-CSC: 0 X-CHA: v=1.1 cv=3vroozmhezBP+7RX62VLXHfNRE6fEyW8fj8TCBGQ830= c=1 sm=1 a=iostHTGYfEUA:10 a=U62ajLuCel8A:10 a=jXKJviUpWSOlMmIvGrHOfw==:17 a=mDV3o1hIAAAA:8 a=_O8DKvIVjKsqxJnpONoA:9 a=8c9ZN546_vyD8CqIx4wA:7 a=jXKJviUpWSOlMmIvGrHOfw==:117 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-11/txt/msg00039.txt.bz2 --- scripts/build/binutils/binutils.sh | 14 +++- scripts/build/cc/gcc.sh | 15 +++- scripts/build/libc/glibc-eglibc.sh-common | 124 +++++++++++++++++++++++++--- 3 files changed, 134 insertions(+), 19 deletions(-) diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh index e082590..9c51a3d 100644 --- a/scripts/build/binutils/binutils.sh +++ b/scripts/build/binutils/binutils.sh @@ -59,6 +59,11 @@ do_binutils() { extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") fi + if [ "${CT_CC_MULTILIB}" = "n" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multilib") + fi CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" @@ -71,7 +76,6 @@ do_binutils() { --target=${CT_TARGET} \ --prefix=${CT_PREFIX_DIR} \ --disable-nls \ - --disable-multilib \ --disable-werror \ "${extra_config[@]}" \ ${CT_ARCH_WITH_FLOAT} \ @@ -151,7 +155,12 @@ do_binutils_target() { extra_config+=("--with-pkgversion=${CT_PKGVERSION}") [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}") fi - + if [ "${CT_CC_MULTILIB}" = "n" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multilib") + fi + CT_DoExecLog CFG \ "${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}/configure" \ --build=${CT_BUILD} \ @@ -162,7 +171,6 @@ do_binutils_target() { --enable-shared \ --enable-static \ --disable-nls \ - --disable-multilib \ "${extra_config[@]}" \ ${CT_ARCH_WITH_FLOAT} \ "${CT_BINUTILS_EXTRA_CONFIG[@]}" diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 05df729..8804e85 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -288,6 +288,12 @@ do_cc_core() { extra_config+=(--disable-libgomp) extra_config+=(--disable-libmudflap) + if [ "${CT_CC_MULTILIB}" = "n" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multilib") + fi + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532) @@ -301,7 +307,6 @@ do_cc_core() { --target=${CT_TARGET} \ --prefix="${core_prefix_dir}" \ --with-local-prefix="${CT_SYSROOT_DIR}" \ - --disable-multilib \ --disable-libmudflap \ ${CC_CORE_SYSROOT_ARG} \ "${extra_config[@]}" \ @@ -424,7 +429,13 @@ do_cc() { lang_opt=$(echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;') extra_config+=("--enable-languages=${lang_opt}") - extra_config+=("--disable-multilib") + + if [ "${CT_CC_MULTILIB}" = "n" ]; then + extra_config+=("--disable-multilib") + else + extra_config+=("--enable-multilib") + fi + for tmp in ARCH ABI CPU TUNE FPU FLOAT; do eval tmp="\${CT_ARCH_WITH_${tmp}}" if [ -n "${tmp}" ]; then 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 @@ -57,18 +57,103 @@ do_libc_extract() { do_libc_start_files() { # Start files and Headers should be configured the same way as the # final libc, but built and installed differently. - do_libc_backend libc_mode=startfiles + do_libc_backend_multilib libc_mode=startfiles } # This function builds and install the full C library do_libc() { - do_libc_backend libc_mode=final + do_libc_backend_multilib libc_mode=final } +# 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 + 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 + 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 ${CT_SYSROOT_DIR}/${d}/${l}.so + else + CT_DoLog WARN "${CT_SYSROOT_DIR}/${d}/${l}.so has already been patched, skipping" + fi + fi + done + done + CT_EndStep + fi + done; + fi +} + +# call do_libc_backend times with varying and options +do_libc_backend_multilib() { + local flags="" + local i + local dir + # We need to call the backend at least once, + # with all settings set to the defaults + do_libc_backend "$@" + 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="${i%%;*}" + if [ "${dir}" != "." ]; then + flags="$(echo $i | ${sed} -r -e 's/^[^;]*;//' -e 's/@/ -/g')"; + CT_DoStep INFO "C Library with multilib. Flags: \"${flags}\" Dir: \"${dir}\"" + do_libc_backend "$@" extra_dir="/${dir}" extra_flags="${flags}" + CT_EndStep + fi + done; + do_libc_backend_rearrange + fi +} + do_libc_backend() { local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" local libc_mode=final local extra_cc_args + local extra_dir="" + local extra_dir_p + local extra_flags="" local -a extra_config local -a extra_make_args local glibc_cflags @@ -77,15 +162,16 @@ do_libc_backend() { eval "${1// /\\ }" shift done - + extra_dir_p="$(echo ${extra_dir} | ${sed} -r -e 's/\///g')" + if [ "${libc_mode}" = "startfiles" ]; then CT_DoStep INFO "Installing C library headers & start files" - mkdir -p "${CT_BUILD_DIR}/build-libc-start-files" - cd "${CT_BUILD_DIR}/build-libc-start-files" + mkdir -p "${CT_BUILD_DIR}/build-libc-start-files${extra_dir_p}" + cd "${CT_BUILD_DIR}/build-libc-start-files${extra_dir_p}" else # libc_mode = final CT_DoStep INFO "Installing C library" - mkdir -p "${CT_BUILD_DIR}/build-libc" - cd "${CT_BUILD_DIR}/build-libc" + mkdir -p "${CT_BUILD_DIR}/build-libc${extra_dir_p}" + cd "${CT_BUILD_DIR}/build-libc${extra_dir_p}" fi CT_DoLog EXTRA "Configuring C library" @@ -133,7 +219,13 @@ do_libc_backend() { esac 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 @@ -173,7 +265,7 @@ do_libc_backend() { CT_DoLog DEBUG "Extra config args passed: '${extra_config[*]}'" CT_DoLog DEBUG "Extra CC args passed : '${extra_cc_args}'" - glibc_cflags="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} ${OPTIMIZE}" + glibc_cflags="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} ${OPTIMIZE} ${extra_flags}" case "${CT_LIBC_ENABLE_FORTIFIED_BUILD}" in y) ;; *) glibc_cflags+=" -U_FORTIFY_SOURCE";; @@ -236,7 +328,7 @@ do_libc_backend() { # use the 'install-headers' makefile target to install the # headers CT_DoExecLog ALL make ${JOBSFLAGS} \ - install_root=${CT_SYSROOT_DIR} \ + install_root=${CT_SYSROOT_DIR}${extra_dir} \ install-bootstrap-headers=yes \ "${extra_make_args[@]}" \ install-headers @@ -273,12 +365,12 @@ do_libc_backend() { # there are a few object files needed to link shared libraries, # which we build and install by hand - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib" + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" CT_DoExecLog ALL make ${JOBSFLAGS} \ "${extra_make_args[@]}" \ csu/subdir_lib CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \ - "${CT_SYSROOT_DIR}/usr/lib" + "${CT_SYSROOT_DIR}${extra_dir}/usr/lib" # Finally, 'libgcc_s.so' requires a 'libc.so' to link against. # However, since we will never actually execute its code, @@ -288,9 +380,13 @@ do_libc_backend() { -nostartfiles \ -shared \ -x c /dev/null \ - -o "${CT_SYSROOT_DIR}/usr/lib/libc.so" + -o "${CT_SYSROOT_DIR}${extra_dir}/usr/lib/libc.so" fi # threads == nptl else # libc_mode = final + CT_DoLog EXTRA "Prepare C library" + CT_DoExecLog ALL make ${JOBSFLAGS} \ + "${extra_make_args[@]}" \ + clean CT_DoLog EXTRA "Building C library" CT_DoExecLog ALL make ${JOBSFLAGS} \ "${extra_make_args[@]}" \ @@ -299,7 +395,7 @@ do_libc_backend() { CT_DoLog EXTRA "Installing C library" CT_DoExecLog ALL make ${JOBSFLAGS} \ "${extra_make_args[@]}" \ - install_root="${CT_SYSROOT_DIR}" \ + install_root="${CT_SYSROOT_DIR}${extra_dir}" \ install if [ "${CT_LIBC_LOCALES}" = "y" ]; then -- 1.6.4.1 -- For unsubscribe information see http://sourceware.org/lists.html#faq