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