1.1 --- a/scripts/build/cc_gcc.sh Thu Sep 11 09:02:00 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,275 +0,0 @@
1.4 -# This file adds the function to build the gcc C compiler
1.5 -# Copyright 2007 Yann E. MORIN
1.6 -# Licensed under the GPL v2. See COPYING in the root of this package
1.7 -
1.8 -do_print_filename() {
1.9 - [ "${CT_CC}" = "gcc" ] || return 0
1.10 - echo "gcc-${CT_CC_VERSION}"
1.11 -}
1.12 -
1.13 -# Download gcc
1.14 -do_cc_get() {
1.15 - # Ah! gcc folks are kind of 'different': they store the tarballs in
1.16 - # subdirectories of the same name! That's because gcc is such /crap/ that
1.17 - # it is such /big/ that it needs being splitted for distribution! Sad. :-(
1.18 - # Arrgghh! Some of those versions does not follow this convention:
1.19 - # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
1.20 - # subdirectory! You bastard!
1.21 - CT_GetFile "${CT_CC_FILE}" \
1.22 - {ftp,http}://ftp.gnu.org/gnu/gcc{,{,/releases}/${CT_CC_FILE}}
1.23 -}
1.24 -
1.25 -# Extract gcc
1.26 -do_cc_extract() {
1.27 - CT_ExtractAndPatch "${CT_CC_FILE}"
1.28 -}
1.29 -
1.30 -#------------------------------------------------------------------------------
1.31 -# Core gcc pass 1
1.32 -do_cc_core_pass_1() {
1.33 - # In case we're NPTL, build the static core gcc;
1.34 - # in any other case, do nothing.
1.35 - case "${CT_THREADS}" in
1.36 - nptl) do_cc_core mode=static build_libgcc=no;;
1.37 - *) ;;
1.38 - esac
1.39 -}
1.40 -
1.41 -# Core gcc pass 2
1.42 -do_cc_core_pass_2() {
1.43 - # In case we're NPTL, build the shared core gcc,
1.44 - # in any other case, build the static core gcc and the target libgcc.
1.45 - case "${CT_THREADS}" in
1.46 - nptl) do_cc_core mode=shared build_libgcc=yes;;
1.47 - *) do_cc_core mode=static build_libgcc=yes;;
1.48 - esac
1.49 -}
1.50 -
1.51 -#------------------------------------------------------------------------------
1.52 -# Build core gcc
1.53 -# This function is used to build both the static and the shared core C conpiler,
1.54 -# with or without the target libgcc. We need to know wether:
1.55 -# - we're building static or shared: mode=[static|shared]
1.56 -# - we need to build libgcc or not: build_libgcc=[yes|no]
1.57 -# Usage: do_cc_core_static mode=[static|shared] build_libgcc=[yes|no]
1.58 -do_cc_core() {
1.59 - local mode
1.60 - local build_libgcc
1.61 - local core_prefix_dir
1.62 - local extra_config
1.63 -
1.64 - eval $1
1.65 - eval $2
1.66 - CT_TestOrAbort "Internal Error: 'mode' must either 'static' or 'shared', not '${mode:-(empty)}'" "${mode}" = "static" -o "${mode}" = "shared"
1.67 - CT_TestOrAbort "Internal Error: 'build_libgcc' must be either 'yes' or 'no', not '${build_libgcc:-(empty)}'" "${build_libgcc}" = "yes" -o "${build_libgcc}" = "no"
1.68 - # In normal conditions, ( "${mode}" = "shared" ) implies
1.69 - # ( "${build_libgcc}" = "yes" ), but I won't check for that
1.70 -
1.71 - mkdir -p "${CT_BUILD_DIR}/build-cc-core-${mode}"
1.72 - cd "${CT_BUILD_DIR}/build-cc-core-${mode}"
1.73 -
1.74 - CT_DoStep INFO "Installing ${mode} core C compiler"
1.75 - case "${mode}" in
1.76 - static)
1.77 - core_prefix_dir="${CT_CC_CORE_STATIC_PREFIX_DIR}"
1.78 - extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
1.79 - ;;
1.80 - shared)
1.81 - core_prefix_dir="${CT_CC_CORE_SHARED_PREFIX_DIR}"
1.82 - extra_config="${extra_config} --enable-shared"
1.83 - ;;
1.84 - esac
1.85 -
1.86 - CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
1.87 - CT_DoExecLog ALL mkdir -p "${core_prefix_dir}/${CT_TARGET}/include"
1.88 - CT_DoExecLog ALL cp -r "${CT_HEADERS_DIR}"/* "${core_prefix_dir}/${CT_TARGET}/include"
1.89 -
1.90 - CT_DoLog EXTRA "Configuring ${mode} core C compiler"
1.91 -
1.92 - extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
1.93 - extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
1.94 - extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
1.95 - extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
1.96 - extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
1.97 - extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
1.98 - [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
1.99 - if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
1.100 - extra_config="${extra_config} --enable-__cxa_atexit"
1.101 - else
1.102 - extra_config="${extra_config} --disable-__cxa_atexit"
1.103 - fi
1.104 -
1.105 - CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
1.106 -
1.107 - # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
1.108 - CC_FOR_BUILD="${CT_CC_NATIVE}" \
1.109 - CFLAGS="${CT_CFLAGS_FOR_HOST}" \
1.110 - CT_DoExecLog ALL \
1.111 - "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
1.112 - ${CT_CANADIAN_OPT} \
1.113 - --host=${CT_HOST} \
1.114 - --target=${CT_TARGET} \
1.115 - --prefix="${core_prefix_dir}" \
1.116 - --with-local-prefix="${CT_SYSROOT_DIR}" \
1.117 - --disable-multilib \
1.118 - ${CC_CORE_SYSROOT_ARG} \
1.119 - ${extra_config} \
1.120 - --disable-nls \
1.121 - --enable-symvers=gnu \
1.122 - --enable-languages=c \
1.123 - --enable-target-optspace \
1.124 - ${CT_CC_CORE_EXTRA_CONFIG}
1.125 -
1.126 - if [ "${build_libgcc}" = "yes" ]; then
1.127 - # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
1.128 - # gcc/config/t-libunwind so -lc is removed from the link for
1.129 - # libgcc_s.so, as we do not have a target -lc yet.
1.130 - # This is not as ugly as it appears to be ;-) All symbols get resolved
1.131 - # during the glibc build, and we provide a proper libgcc_s.so for the
1.132 - # cross toolchain during the final gcc build.
1.133 - #
1.134 - # As we cannot modify the source tree, nor override SHLIB_LC itself
1.135 - # during configure or make, we have to edit the resultant
1.136 - # gcc/libgcc.mk itself to remove -lc from the link.
1.137 - # This causes us to have to jump through some hoops...
1.138 - #
1.139 - # To produce libgcc.mk to edit we firstly require libiberty.a,
1.140 - # so we configure then build it.
1.141 - # Next we have to configure gcc, create libgcc.mk then edit it...
1.142 - # So much easier if we just edit the source tree, but hey...
1.143 - if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
1.144 - CT_DoExecLog ALL make configure-libiberty
1.145 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
1.146 - CT_DoExecLog ALL make configure-gcc configure-libcpp
1.147 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
1.148 - else
1.149 - CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
1.150 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
1.151 - fi
1.152 - # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
1.153 - if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
1.154 - CT_DoExecLog ALL make configure-libdecnumber
1.155 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
1.156 - fi
1.157 -
1.158 - # Starting with GCC 4.3, libgcc.mk is no longer built,
1.159 - # and libgcc.mvars is used instead.
1.160 -
1.161 - gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
1.162 - gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
1.163 -
1.164 - if [ ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3 \
1.165 - -o ${gcc_version_major} -gt 4 ]; then
1.166 - libgcc_rule="libgcc.mvars"
1.167 - build_rules="all-gcc all-target-libgcc"
1.168 - install_rules="install-gcc install-target-libgcc"
1.169 - else
1.170 - libgcc_rule="libgcc.mk"
1.171 - build_rules="all-gcc"
1.172 - install_rules="install-gcc"
1.173 - fi
1.174 -
1.175 - CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
1.176 - sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
1.177 - else # build_libgcc
1.178 - build_rules="all-gcc"
1.179 - install_rules="install-gcc"
1.180 - fi # ! build libgcc
1.181 -
1.182 - if [ "${CT_CANADIAN}" = "y" ]; then
1.183 - CT_DoLog EXTRA "Building libiberty"
1.184 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
1.185 - fi
1.186 -
1.187 - CT_DoLog EXTRA "Building ${mode} core C compiler"
1.188 - CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
1.189 -
1.190 - CT_DoLog EXTRA "Installing ${mode} core C compiler"
1.191 - CT_DoExecLog ALL make ${install_rules}
1.192 -
1.193 - CT_EndStep
1.194 -}
1.195 -
1.196 -#------------------------------------------------------------------------------
1.197 -# Build final gcc
1.198 -do_cc() {
1.199 - CT_DoStep INFO "Installing final compiler"
1.200 -
1.201 - mkdir -p "${CT_BUILD_DIR}/build-cc"
1.202 - cd "${CT_BUILD_DIR}/build-cc"
1.203 -
1.204 - CT_DoLog EXTRA "Configuring final compiler"
1.205 -
1.206 - # Enable selected languages
1.207 - lang_opt="c"
1.208 - [ "${CT_CC_LANG_CXX}" = "y" ] && lang_opt="${lang_opt},c++"
1.209 - [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_opt="${lang_opt},fortran"
1.210 - [ "${CT_CC_LANG_ADA}" = "y" ] && lang_opt="${lang_opt},ada"
1.211 - [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_opt="${lang_opt},java"
1.212 - [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_opt="${lang_opt},objc"
1.213 - [ "${CT_CC_LANG_OBJCXX}" = "y" ] && lang_opt="${lang_opt},obj-c++"
1.214 - CT_Test "Building ADA language is not yet supported. Will try..." "${CT_CC_LANG_ADA}" = "y"
1.215 - CT_Test "Building Objective-C language is not yet supported. Will try..." "${CT_CC_LANG_OBJC}" = "y"
1.216 - CT_Test "Building Objective-C++ language is not yet supported. Will try..." "${CT_CC_LANG_OBJCXX}" = "y"
1.217 - CT_Test "Building ${CT_CC_LANG_OTHERS//,/ } language(s) is not yet supported. Will try..." -n "${CT_CC_LANG_OTHERS}"
1.218 - lang_opt=$(echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;')
1.219 -
1.220 - extra_config="--enable-languages=${lang_opt}"
1.221 - extra_config="${extra_config} --disable-multilib"
1.222 - extra_config="${extra_config} ${CT_ARCH_WITH_ARCH} ${CT_ARCH_WITH_ABI} ${CT_ARCH_WITH_CPU} ${CT_ARCH_WITH_TUNE} ${CT_ARCH_WITH_FPU} ${CT_ARCH_WITH_FLOAT}"
1.223 - [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
1.224 - [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
1.225 - [ -n "${CT_CC_PKGVERSION}" ] && extra_config="${extra_config} --with-pkgversion=${CT_CC_PKGVERSION}"
1.226 - [ -n "${CT_CC_BUGURL}" ] && extra_config="${extra_config} --with-bugurl=${CT_CC_BUGURL}"
1.227 - [ "${CT_CC_SJLJ_EXCEPTIONS_USE}" = "y" ] && extra_config="${extra_config} --enable-sjlj-exceptions"
1.228 - [ "${CT_CC_SJLJ_EXCEPTIONS_DONT_USE}" = "y" ] && extra_config="${extra_config} --disable-sjlj-exceptions"
1.229 - if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
1.230 - extra_config="${extra_config} --enable-__cxa_atexit"
1.231 - else
1.232 - extra_config="${extra_config} --disable-__cxa_atexit"
1.233 - fi
1.234 -
1.235 - CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
1.236 -
1.237 - # --enable-symvers=gnu really only needed for sh4 to work around a
1.238 - # detection problem only matters for gcc-3.2.x and later, I think.
1.239 - # --disable-nls to work around crash bug on ppc405, but also because
1.240 - # embedded systems don't really need message catalogs...
1.241 - CC_FOR_BUILD="${CT_CC_NATIVE}" \
1.242 - CFLAGS="${CT_CFLAGS_FOR_HOST}" \
1.243 - CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
1.244 - CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
1.245 - LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}" \
1.246 - CT_DoExecLog ALL \
1.247 - "${CT_SRC_DIR}/${CT_CC_FILE}/configure" \
1.248 - ${CT_CANADIAN_OPT} \
1.249 - --target=${CT_TARGET} --host=${CT_HOST} \
1.250 - --prefix="${CT_PREFIX_DIR}" \
1.251 - ${CC_SYSROOT_ARG} \
1.252 - ${extra_config} \
1.253 - --with-local-prefix="${CT_SYSROOT_DIR}" \
1.254 - --disable-nls \
1.255 - --enable-threads=posix \
1.256 - --enable-symvers=gnu \
1.257 - --enable-c99 \
1.258 - --enable-long-long \
1.259 - --enable-target-optspace \
1.260 - ${CT_CC_EXTRA_CONFIG}
1.261 -
1.262 - if [ "${CT_CANADIAN}" = "y" ]; then
1.263 - CT_DoLog EXTRA "Building libiberty"
1.264 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
1.265 - fi
1.266 -
1.267 - CT_DoLog EXTRA "Building final compiler"
1.268 - CT_DoExecLog ALL make ${PARALLELMFLAGS} all
1.269 -
1.270 - CT_DoLog EXTRA "Installing final compiler"
1.271 - CT_DoExecLog ALL make install
1.272 -
1.273 - # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
1.274 - # to call the C compiler with the same, somewhat canonical name.
1.275 - ln -sv "${CT_PREFIX_DIR}/bin/${CT_TARGET}"-{g,}cc 2>&1 |CT_DoLog ALL
1.276 -
1.277 - CT_EndStep
1.278 -}