Fix building core C compiler.
PowerPC unveiled that you can't reliably build a target libgcc until you have C library headers.
In fact you can't build it at all. The fact that it did build for some architectures was purely coincidental, and a mistake.
This fix should still allow to build uClibc-based toolchains (some ARM uClibc toolchains were build-tested).
/trunk/scripts/build/cc_gcc.sh | 100 47 53 0 +++++++++++++++++++++++-------------------------
1 file changed, 47 insertions(+), 53 deletions(-)
1.1 --- a/scripts/build/cc_gcc.sh Thu Aug 07 07:52:09 2008 +0000
1.2 +++ b/scripts/build/cc_gcc.sh Thu Aug 07 13:28:02 2008 +0000
1.3 @@ -30,23 +30,28 @@
1.4 # In case we're NPTL, build the static core gcc;
1.5 # in any other case, do nothing.
1.6 case "${CT_THREADS}" in
1.7 - nptl) do_cc_core_static;;
1.8 + nptl) do_cc_core_static build_libgcc=no;;
1.9 esac
1.10 }
1.11
1.12 # Core gcc pass 2
1.13 do_cc_core_pass_2() {
1.14 # In case we're NPTL, build the shared core gcc,
1.15 - # in any other case, build the static core gcc.
1.16 + # in any other case, build the static core gcc and the target libgcc.
1.17 case "${CT_THREADS}" in
1.18 nptl) do_cc_core_shared;;
1.19 - *) do_cc_core_static;;
1.20 + *) do_cc_core_static build_libgcc=yes;;
1.21 esac
1.22 }
1.23
1.24 #------------------------------------------------------------------------------
1.25 # Build static core gcc
1.26 +# We need to know wether to build the target libgcc!
1.27 +# Usage: do_cc_core_static <build_libgcc=[yes|no]>
1.28 do_cc_core_static() {
1.29 + eval $1
1.30 + CT_TestOrAbort "Internal Error: '$0' does not know wether to build, or not to build, target libgcc" -n "${build_libgcc}"
1.31 +
1.32 mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
1.33 cd "${CT_BUILD_DIR}/build-cc-core-static"
1.34
1.35 @@ -90,56 +95,45 @@
1.36 --enable-target-optspace \
1.37 ${CT_CC_CORE_EXTRA_CONFIG}
1.38
1.39 - # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
1.40 - # gcc/config/t-libunwind so -lc is removed from the link for
1.41 - # libgcc_s.so, as we do not have a target -lc yet.
1.42 - # This is not as ugly as it appears to be ;-) All symbols get resolved
1.43 - # during the glibc build, and we provide a proper libgcc_s.so for the
1.44 - # cross toolchain during the final gcc build.
1.45 - #
1.46 - # As we cannot modify the source tree, nor override SHLIB_LC itself
1.47 - # during configure or make, we have to edit the resultant
1.48 - # gcc/libgcc.mk itself to remove -lc from the link.
1.49 - # This causes us to have to jump through some hoops...
1.50 - #
1.51 - # To produce libgcc.mk to edit we firstly require libiberty.a,
1.52 - # so we configure then build it.
1.53 - # Next we have to configure gcc, create libgcc.mk then edit it...
1.54 - # So much easier if we just edit the source tree, but hey...
1.55 - if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
1.56 - CT_DoExecLog ALL make configure-libiberty
1.57 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
1.58 - CT_DoExecLog ALL make configure-gcc configure-libcpp
1.59 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
1.60 - else
1.61 - CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
1.62 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
1.63 - fi
1.64 - # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
1.65 - if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
1.66 - CT_DoExecLog ALL make configure-libdecnumber
1.67 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
1.68 - fi
1.69 + if [ "${build_libgcc}" = "yes" ]; then
1.70 + if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
1.71 + CT_DoExecLog ALL make configure-libiberty
1.72 + CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
1.73 + CT_DoExecLog ALL make configure-gcc configure-libcpp
1.74 + CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
1.75 + else
1.76 + CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
1.77 + CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
1.78 + fi
1.79 + # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
1.80 + if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
1.81 + CT_DoExecLog ALL make configure-libdecnumber
1.82 + CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
1.83 + fi
1.84
1.85 - # Starting with GCC 4.3, libgcc.mk is no longer built,
1.86 - # and libgcc.mvars is used instead.
1.87 + # Starting with GCC 4.3, libgcc.mk is no longer built,
1.88 + # and libgcc.mvars is used instead.
1.89
1.90 - gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
1.91 - gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
1.92 + gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
1.93 + gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
1.94
1.95 - if [ ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3 \
1.96 - -o ${gcc_version_major} -gt 4 ]; then
1.97 - libgcc_rule="libgcc.mvars"
1.98 - build_rules="all-gcc all-target-libgcc"
1.99 - install_rules="install-gcc install-target-libgcc"
1.100 - else
1.101 - libgcc_rule="libgcc.mk"
1.102 - build_rules="all-gcc"
1.103 - install_rules="install-gcc"
1.104 - fi
1.105 + if [ ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3 \
1.106 + -o ${gcc_version_major} -gt 4 ]; then
1.107 + libgcc_rule="libgcc.mvars"
1.108 + build_rules="all-gcc all-target-libgcc"
1.109 + install_rules="install-gcc install-target-libgcc"
1.110 + else
1.111 + libgcc_rule="libgcc.mk"
1.112 + build_rules="all-gcc"
1.113 + install_rules="install-gcc"
1.114 + fi
1.115
1.116 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
1.117 - sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
1.118 + CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
1.119 + sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
1.120 + else # build_libgcc
1.121 + build_rules="all-gcc"
1.122 + install_rules="install-gcc"
1.123 + fi # ! build libgcc
1.124
1.125 if [ "${CT_CANADIAN}" = "y" ]; then
1.126 CT_DoLog EXTRA "Building libiberty"