1.1 --- a/scripts/build/cc_gcc.sh Thu Jul 12 08:46:50 2007 +0000
1.2 +++ b/scripts/build/cc_gcc.sh Wed Aug 15 10:14:43 2007 +0000
1.3 @@ -1,4 +1,4 @@
1.4 -# This file adds the function to build the final gcc C compiler
1.5 +# This file adds the function to build the gcc C compiler
1.6 # Copyright 2007 Yann E. MORIN
1.7 # Licensed under the GPL v2. See COPYING in the root of this package
1.8
1.9 @@ -26,6 +26,178 @@
1.10 CT_ExtractAndPatch "${CT_CC_FILE}"
1.11 }
1.12
1.13 +#------------------------------------------------------------------------------
1.14 +# Core gcc pass 1
1.15 +do_cc_core_pass_1() {
1.16 + # In case we're NPTL, build the static core gcc;
1.17 + # in any other case, do nothing.
1.18 + case "${CT_THREADS}" in
1.19 + nptl) do_cc_core_static;;
1.20 + *) ;;
1.21 + esac
1.22 +}
1.23 +
1.24 +# Core gcc pass 2
1.25 +do_cc_core_pass_2() {
1.26 + # In case we're NPTL, build the shared core gcc,
1.27 + # in any other case, build the static core gcc.
1.28 + case "${CT_THREADS}" in
1.29 + nptl) do_cc_core_shared;;
1.30 + *) do_cc_core_static;;
1.31 + esac
1.32 +}
1.33 +
1.34 +#------------------------------------------------------------------------------
1.35 +# Build static core gcc
1.36 +do_cc_core_static() {
1.37 + mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
1.38 + cd "${CT_BUILD_DIR}/build-cc-core-static"
1.39 +
1.40 + CT_DoStep INFO "Installing static core C compiler"
1.41 +
1.42 + CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
1.43 + mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
1.44 + cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
1.45 +
1.46 + CT_DoLog EXTRA "Configuring static core C compiler"
1.47 +
1.48 + extra_config=""
1.49 + [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
1.50 + [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
1.51 + [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
1.52 + [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
1.53 + [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
1.54 + [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
1.55 + [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
1.56 +
1.57 + CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
1.58 +
1.59 + # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
1.60 + CFLAGS="${CT_CFLAGS_FOR_HOST}" \
1.61 + "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
1.62 + ${CT_CANADIAN_OPT} \
1.63 + --host=${CT_HOST} \
1.64 + --target=${CT_TARGET} \
1.65 + --prefix="${CT_CC_CORE_STATIC_PREFIX_DIR}" \
1.66 + --with-local-prefix="${CT_SYSROOT_DIR}" \
1.67 + --disable-multilib \
1.68 + --with-newlib \
1.69 + ${CC_CORE_SYSROOT_ARG} \
1.70 + ${extra_config} \
1.71 + --disable-nls \
1.72 + --enable-threads=no \
1.73 + --enable-symvers=gnu \
1.74 + --enable-languages=c \
1.75 + --disable-shared \
1.76 + ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
1.77 +
1.78 + if [ "${CT_CANADIAN}" = "y" ]; then
1.79 + CT_DoLog EXTRA "Building libiberty"
1.80 + make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
1.81 + fi
1.82 +
1.83 + CT_DoLog EXTRA "Building static core C compiler"
1.84 + make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
1.85 +
1.86 + CT_DoLog EXTRA "Installing static core C compiler"
1.87 + make install-gcc 2>&1 |CT_DoLog ALL
1.88 +
1.89 + CT_EndStep
1.90 +}
1.91 +
1.92 +#------------------------------------------------------------------------------
1.93 +# Build shared core gcc
1.94 +do_cc_core_shared() {
1.95 + mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
1.96 + cd "${CT_BUILD_DIR}/build-cc-core-shared"
1.97 +
1.98 + CT_DoStep INFO "Installing shared core C compiler"
1.99 +
1.100 + CT_DoLog EXTRA "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
1.101 + mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
1.102 + cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
1.103 +
1.104 + CT_DoLog EXTRA "Configuring shared core C compiler"
1.105 +
1.106 + extra_config=""
1.107 + [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
1.108 + [ -n "${CT_ARCH_ABI}" ] && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
1.109 + [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
1.110 + [ -n "${CT_ARCH_CPU}" ] && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
1.111 + [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
1.112 + [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
1.113 + [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
1.114 +
1.115 + CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
1.116 +
1.117 + CFLAGS="${CT_CFLAGS_FOR_HOST}" \
1.118 + "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
1.119 + ${CT_CANADIAN_OPT} \
1.120 + --target=${CT_TARGET} \
1.121 + --host=${CT_HOST} \
1.122 + --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}" \
1.123 + --with-local-prefix="${CT_SYSROOT_DIR}" \
1.124 + --disable-multilib \
1.125 + ${CC_CORE_SYSROOT_ARG} \
1.126 + ${extra_config} \
1.127 + --disable-nls \
1.128 + --enable-symvers=gnu \
1.129 + --enable-languages=c \
1.130 + --enable-shared \
1.131 + ${CT_CC_CORE_EXTRA_CONFIG} 2>&1 |CT_DoLog ALL
1.132 +
1.133 + # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
1.134 + # gcc/config/t-libunwind so -lc is removed from the link for
1.135 + # libgcc_s.so, as we do not have a target -lc yet.
1.136 + # This is not as ugly as it appears to be ;-) All symbols get resolved
1.137 + # during the glibc build, and we provide a proper libgcc_s.so for the
1.138 + # cross toolchain during the final gcc build.
1.139 + #
1.140 + # As we cannot modify the source tree, nor override SHLIB_LC itself
1.141 + # during configure or make, we have to edit the resultant
1.142 + # gcc/libgcc.mk itself to remove -lc from the link.
1.143 + # This causes us to have to jump through some hoops...
1.144 + #
1.145 + # To produce libgcc.mk to edit we firstly require libiberty.a,
1.146 + # so we configure then build it.
1.147 + # Next we have to configure gcc, create libgcc.mk then edit it...
1.148 + # So much easier if we just edit the source tree, but hey...
1.149 + if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
1.150 + make configure-libiberty
1.151 + make -C libiberty libiberty.a
1.152 + make configure-gcc
1.153 + make configure-libcpp
1.154 + make all-libcpp
1.155 + else
1.156 + make configure-gcc
1.157 + make configure-libcpp
1.158 + make configure-build-libiberty
1.159 + make all-libcpp
1.160 + make all-build-libiberty
1.161 + fi 2>&1 |CT_DoLog ALL
1.162 + # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
1.163 + if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
1.164 + make configure-libdecnumber
1.165 + make -C libdecnumber libdecnumber.a
1.166 + fi 2>&1 |CT_DoLog ALL
1.167 + make -C gcc libgcc.mk 2>&1 |CT_DoLog ALL
1.168 + sed -r -i -e 's@-lc@@g' gcc/libgcc.mk
1.169 +
1.170 + if [ "${CT_CANADIAN}" = "y" ]; then
1.171 + CT_DoLog EXTRA "Building libiberty"
1.172 + make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
1.173 + fi
1.174 +
1.175 + CT_DoLog EXTRA "Building shared core C compiler"
1.176 + make ${PARALLELMFLAGS} all-gcc 2>&1 |CT_DoLog ALL
1.177 +
1.178 + CT_DoLog EXTRA "Installing shared core C compiler"
1.179 + make install-gcc 2>&1 |CT_DoLog ALL
1.180 +
1.181 + CT_EndStep
1.182 +}
1.183 +
1.184 +#------------------------------------------------------------------------------
1.185 # Build final gcc
1.186 do_cc() {
1.187 CT_DoStep INFO "Installing final compiler"