scripts/build/cc_gcc.sh
changeset 757 90e887b06da3
parent 740 d26d8cc7c460
child 763 f078be5961ec
     1.1 --- a/scripts/build/cc_gcc.sh	Sun Jul 27 16:35:37 2008 +0000
     1.2 +++ b/scripts/build/cc_gcc.sh	Mon Aug 04 12:38:06 2008 +0000
     1.3 @@ -90,16 +90,67 @@
     1.4          --enable-target-optspace                    \
     1.5          ${CT_CC_CORE_EXTRA_CONFIG}
     1.6  
     1.7 +    # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
     1.8 +    # gcc/config/t-libunwind so -lc is removed from the link for
     1.9 +    # libgcc_s.so, as we do not have a target -lc yet.
    1.10 +    # This is not as ugly as it appears to be ;-) All symbols get resolved
    1.11 +    # during the glibc build, and we provide a proper libgcc_s.so for the
    1.12 +    # cross toolchain during the final gcc build.
    1.13 +    #
    1.14 +    # As we cannot modify the source tree, nor override SHLIB_LC itself
    1.15 +    # during configure or make, we have to edit the resultant
    1.16 +    # gcc/libgcc.mk itself to remove -lc from the link.
    1.17 +    # This causes us to have to jump through some hoops...
    1.18 +    #
    1.19 +    # To produce libgcc.mk to edit we firstly require libiberty.a,
    1.20 +    # so we configure then build it.
    1.21 +    # Next we have to configure gcc, create libgcc.mk then edit it...
    1.22 +    # So much easier if we just edit the source tree, but hey...
    1.23 +    if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
    1.24 +        CT_DoExecLog ALL make configure-libiberty
    1.25 +        CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
    1.26 +        CT_DoExecLog ALL make configure-gcc configure-libcpp
    1.27 +        CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
    1.28 +    else
    1.29 +        CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
    1.30 +        CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
    1.31 +    fi
    1.32 +    # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
    1.33 +    if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
    1.34 +        CT_DoExecLog ALL make configure-libdecnumber
    1.35 +        CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
    1.36 +    fi
    1.37 +
    1.38 +    # Starting with GCC 4.3, libgcc.mk is no longer built,
    1.39 +    # and libgcc.mvars is used instead.
    1.40 +
    1.41 +    gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
    1.42 +    gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
    1.43 +
    1.44 +    if [    ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3    \
    1.45 +         -o ${gcc_version_major} -gt 4                                  ]; then
    1.46 +        libgcc_rule="libgcc.mvars"
    1.47 +        build_rules="all-gcc all-target-libgcc"
    1.48 +        install_rules="install-gcc install-target-libgcc"
    1.49 +    else
    1.50 +        libgcc_rule="libgcc.mk"
    1.51 +        build_rules="all-gcc"
    1.52 +        install_rules="install-gcc"
    1.53 +    fi
    1.54 +
    1.55 +    CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
    1.56 +    sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
    1.57 +
    1.58      if [ "${CT_CANADIAN}" = "y" ]; then
    1.59          CT_DoLog EXTRA "Building libiberty"
    1.60          CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
    1.61      fi
    1.62  
    1.63      CT_DoLog EXTRA "Building static core C compiler"
    1.64 -    CT_DoExecLog ALL make ${PARALLELMFLAGS} all-gcc
    1.65 +    CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
    1.66  
    1.67      CT_DoLog EXTRA "Installing static core C compiler"
    1.68 -    CT_DoExecLog ALL make install-gcc
    1.69 +    CT_DoExecLog ALL make ${install_rules}
    1.70  
    1.71      CT_EndStep
    1.72  }