Merge the static and shared core gcc builds.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 12 07:47:51 2008 +0000 (2008-08-12)
changeset 78925e71f078a2d
parent 788 cc9721772cc6
child 790 1007f2b72414
Merge the static and shared core gcc builds.

/trunk/scripts/build/cc_gcc.sh | 195 64 131 0 ++++++++++++++++--------------------------------
1 file changed, 64 insertions(+), 131 deletions(-)
scripts/build/cc_gcc.sh
     1.1 --- a/scripts/build/cc_gcc.sh	Tue Aug 12 07:47:19 2008 +0000
     1.2 +++ b/scripts/build/cc_gcc.sh	Tue Aug 12 07:47:51 2008 +0000
     1.3 @@ -30,7 +30,8 @@
     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 build_libgcc=no;;
     1.8 +        nptl)   do_cc_core mode=static build_libgcc=no;;
     1.9 +        *)      ;;
    1.10      esac
    1.11  }
    1.12  
    1.13 @@ -39,31 +40,58 @@
    1.14      # In case we're NPTL, build the shared core gcc,
    1.15      # in any other case, build the static core gcc and the target libgcc.
    1.16      case "${CT_THREADS}" in
    1.17 -        nptl)   do_cc_core_shared;;
    1.18 -        *)      do_cc_core_static build_libgcc=yes;;
    1.19 +        nptl)   do_cc_core mode=shared build_libgcc=yes;;
    1.20 +        *)      do_cc_core mode=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 +# Build core gcc
    1.30 +# This function is used to build both the static and the shared core C conpiler,
    1.31 +# with or without the target libgcc. We need to know wether:
    1.32 +#  - we're building static or shared: mode=[static|shared]
    1.33 +#  - we need to build libgcc or not:  build_libgcc=[yes|no]
    1.34 +# Usage: do_cc_core_static mode=[static|shared] build_libgcc=[yes|no]
    1.35 +do_cc_core() {
    1.36 +    local mode
    1.37 +    local build_libgcc
    1.38 +    local core_prefix_dir
    1.39 +    local extra_config
    1.40 +
    1.41      eval $1
    1.42 -    CT_TestOrAbort "Internal Error: '$0' does not know wether to build, or not to build, target libgcc" -n "${build_libgcc}"
    1.43 +    eval $2
    1.44 +    CT_TestOrAbort "Internal Error: 'mode' must either 'static' or 'shared', not '${mode:-(empty)}'" "${mode}" = "static" -o "${mode}" = "shared"
    1.45 +    CT_TestOrAbort "Internal Error: 'build_libgcc' must be either 'yes' or 'no', not '${build_libgcc:-(empty)}'" "${build_libgcc}" = "yes" -o "${build_libgcc}" = "no"
    1.46 +    # In normal conditions, ( "${mode}" = "shared" ) implies
    1.47 +    # ( "${build_libgcc}" = "yes" ), but I won't check for that
    1.48  
    1.49 -    mkdir -p "${CT_BUILD_DIR}/build-cc-core-static"
    1.50 -    cd "${CT_BUILD_DIR}/build-cc-core-static"
    1.51 +    mkdir -p "${CT_BUILD_DIR}/build-cc-core-${mode}"
    1.52 +    cd "${CT_BUILD_DIR}/build-cc-core-${mode}"
    1.53  
    1.54 -    CT_DoStep INFO "Installing static core C compiler"
    1.55 +    CT_DoStep INFO "Installing ${mode} core C compiler"
    1.56 +    case "${mode}" in
    1.57 +        static)
    1.58 +            core_prefix_dir="${CT_CC_CORE_STATIC_PREFIX_DIR}"
    1.59 +            extra_config="${extra_config} --with-newlib --enable-threads=no --disable-shared"
    1.60 +            ;;
    1.61 +        shared)
    1.62 +            core_prefix_dir="${CT_CC_CORE_SHARED_PREFIX_DIR}"
    1.63 +            extra_config="${extra_config} --enable-shared"
    1.64 +            ;;
    1.65 +    esac
    1.66  
    1.67      CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
    1.68 -    mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include"
    1.69 -    cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_STATIC_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
    1.70 +    CT_DoExecLog ALL mkdir -p "${core_prefix_dir}/${CT_TARGET}/include"
    1.71 +    CT_DoExecLog ALL cp -r "${CT_HEADERS_DIR}"/* "${core_prefix_dir}/${CT_TARGET}/include"
    1.72  
    1.73 -    CT_DoLog EXTRA "Configuring static core C compiler"
    1.74 +    CT_DoLog EXTRA "Configuring ${mode} core C compiler"
    1.75  
    1.76 -    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.77 +    extra_config="${extra_config} ${CT_ARCH_WITH_ARCH}"
    1.78 +    extra_config="${extra_config} ${CT_ARCH_WITH_ABI}"
    1.79 +    extra_config="${extra_config} ${CT_ARCH_WITH_CPU}"
    1.80 +    extra_config="${extra_config} ${CT_ARCH_WITH_TUNE}"
    1.81 +    extra_config="${extra_config} ${CT_ARCH_WITH_FPU}"
    1.82 +    extra_config="${extra_config} ${CT_ARCH_WITH_FLOAT}"
    1.83      [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
    1.84      if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
    1.85          extra_config="${extra_config} --enable-__cxa_atexit"
    1.86 @@ -81,21 +109,34 @@
    1.87          ${CT_CANADIAN_OPT}                          \
    1.88          --host=${CT_HOST}                           \
    1.89          --target=${CT_TARGET}                       \
    1.90 -        --prefix="${CT_CC_CORE_STATIC_PREFIX_DIR}"  \
    1.91 +        --prefix="${core_prefix_dir}"               \
    1.92          --with-local-prefix="${CT_SYSROOT_DIR}"     \
    1.93          --disable-multilib                          \
    1.94 -        --with-newlib                               \
    1.95          ${CC_CORE_SYSROOT_ARG}                      \
    1.96          ${extra_config}                             \
    1.97          --disable-nls                               \
    1.98 -        --enable-threads=no                         \
    1.99          --enable-symvers=gnu                        \
   1.100          --enable-languages=c                        \
   1.101 -        --disable-shared                            \
   1.102          --enable-target-optspace                    \
   1.103          ${CT_CC_CORE_EXTRA_CONFIG}
   1.104  
   1.105      if [ "${build_libgcc}" = "yes" ]; then
   1.106 +        # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
   1.107 +        # gcc/config/t-libunwind so -lc is removed from the link for
   1.108 +        # libgcc_s.so, as we do not have a target -lc yet.
   1.109 +        # This is not as ugly as it appears to be ;-) All symbols get resolved
   1.110 +        # during the glibc build, and we provide a proper libgcc_s.so for the
   1.111 +        # cross toolchain during the final gcc build.
   1.112 +        #
   1.113 +        # As we cannot modify the source tree, nor override SHLIB_LC itself
   1.114 +        # during configure or make, we have to edit the resultant
   1.115 +        # gcc/libgcc.mk itself to remove -lc from the link.
   1.116 +        # This causes us to have to jump through some hoops...
   1.117 +        #
   1.118 +        # To produce libgcc.mk to edit we firstly require libiberty.a,
   1.119 +        # so we configure then build it.
   1.120 +        # Next we have to configure gcc, create libgcc.mk then edit it...
   1.121 +        # So much easier if we just edit the source tree, but hey...
   1.122          if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
   1.123              CT_DoExecLog ALL make configure-libiberty
   1.124              CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
   1.125 @@ -140,118 +181,10 @@
   1.126          CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
   1.127      fi
   1.128  
   1.129 -    CT_DoLog EXTRA "Building static core C compiler"
   1.130 +    CT_DoLog EXTRA "Building ${mode} core C compiler"
   1.131      CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
   1.132  
   1.133 -    CT_DoLog EXTRA "Installing static core C compiler"
   1.134 -    CT_DoExecLog ALL make ${install_rules}
   1.135 -
   1.136 -    CT_EndStep
   1.137 -}
   1.138 -
   1.139 -#------------------------------------------------------------------------------
   1.140 -# Build shared core gcc
   1.141 -do_cc_core_shared() {
   1.142 -    mkdir -p "${CT_BUILD_DIR}/build-cc-core-shared"
   1.143 -    cd "${CT_BUILD_DIR}/build-cc-core-shared"
   1.144 -
   1.145 -    CT_DoStep INFO "Installing shared core C compiler"
   1.146 -
   1.147 -    CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
   1.148 -    mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include"
   1.149 -    cp -r "${CT_HEADERS_DIR}"/* "${CT_CC_CORE_SHARED_PREFIX_DIR}/${CT_TARGET}/include" 2>&1 |CT_DoLog DEBUG
   1.150 -
   1.151 -    CT_DoLog EXTRA "Configuring shared core C compiler"
   1.152 -
   1.153 -    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.154 -    [ "${CT_GMP_MPFR}" = "y" ] && extra_config="${extra_config} --with-gmp=${CT_PREFIX_DIR} --with-mpfr=${CT_PREFIX_DIR}"
   1.155 -    if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
   1.156 -        extra_config="${extra_config} --enable-__cxa_atexit"
   1.157 -    else
   1.158 -        extra_config="${extra_config} --disable-__cxa_atexit"
   1.159 -    fi
   1.160 -
   1.161 -    CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
   1.162 -
   1.163 -    CC_FOR_BUILD="${CT_CC_NATIVE}"                  \
   1.164 -    CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
   1.165 -    CT_DoExecLog ALL                                \
   1.166 -    "${CT_SRC_DIR}/${CT_CC_FILE}/configure"         \
   1.167 -        ${CT_CANADIAN_OPT}                          \
   1.168 -        --target=${CT_TARGET}                       \
   1.169 -        --host=${CT_HOST}                           \
   1.170 -        --prefix="${CT_CC_CORE_SHARED_PREFIX_DIR}"  \
   1.171 -        --with-local-prefix="${CT_SYSROOT_DIR}"     \
   1.172 -        --disable-multilib                          \
   1.173 -        ${CC_CORE_SYSROOT_ARG}                      \
   1.174 -        ${extra_config}                             \
   1.175 -        --disable-nls                               \
   1.176 -        --enable-symvers=gnu                        \
   1.177 -        --enable-languages=c                        \
   1.178 -        --enable-shared                             \
   1.179 -        --enable-target-optspace                    \
   1.180 -        ${CT_CC_CORE_EXTRA_CONFIG}
   1.181 -
   1.182 -    # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
   1.183 -    # gcc/config/t-libunwind so -lc is removed from the link for
   1.184 -    # libgcc_s.so, as we do not have a target -lc yet.
   1.185 -    # This is not as ugly as it appears to be ;-) All symbols get resolved
   1.186 -    # during the glibc build, and we provide a proper libgcc_s.so for the
   1.187 -    # cross toolchain during the final gcc build.
   1.188 -    #
   1.189 -    # As we cannot modify the source tree, nor override SHLIB_LC itself
   1.190 -    # during configure or make, we have to edit the resultant
   1.191 -    # gcc/libgcc.mk itself to remove -lc from the link.
   1.192 -    # This causes us to have to jump through some hoops...
   1.193 -    #
   1.194 -    # To produce libgcc.mk to edit we firstly require libiberty.a,
   1.195 -    # so we configure then build it.
   1.196 -    # Next we have to configure gcc, create libgcc.mk then edit it...
   1.197 -    # So much easier if we just edit the source tree, but hey...
   1.198 -    if [ ! -f "${CT_SRC_DIR}/${CT_CC_FILE}/gcc/BASE-VER" ]; then
   1.199 -        CT_DoExecLog ALL make configure-libiberty
   1.200 -        CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libiberty libiberty.a
   1.201 -        CT_DoExecLog ALL make configure-gcc configure-libcpp
   1.202 -        CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp
   1.203 -    else
   1.204 -        CT_DoExecLog ALL make configure-gcc configure-libcpp configure-build-libiberty
   1.205 -        CT_DoExecLog ALL make ${PARALLELMFLAGS} all-libcpp all-build-libiberty
   1.206 -    fi
   1.207 -    # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
   1.208 -    if [ -d "${CT_SRC_DIR}/${CT_CC_FILE}/libdecnumber" ]; then
   1.209 -        CT_DoExecLog ALL make configure-libdecnumber
   1.210 -        CT_DoExecLog ALL make ${PARALLELMFLAGS} -C libdecnumber libdecnumber.a
   1.211 -    fi
   1.212 -
   1.213 -    # Starting with GCC 4.3, libgcc.mk is no longer built,
   1.214 -    # and libgcc.mvars is used instead.
   1.215 -
   1.216 -    gcc_version_major=$(echo ${CT_CC_VERSION} |sed -r -e 's/^([^\.]+)\..*/\1/')
   1.217 -    gcc_version_minor=$(echo ${CT_CC_VERSION} |sed -r -e 's/^[^\.]+\.([^.]+).*/\1/')
   1.218 -
   1.219 -    if [    ${gcc_version_major} -eq 4 -a ${gcc_version_minor} -ge 3    \
   1.220 -         -o ${gcc_version_major} -gt 4                                  ]; then
   1.221 -        libgcc_rule="libgcc.mvars"
   1.222 -        build_rules="all-gcc all-target-libgcc"
   1.223 -        install_rules="install-gcc install-target-libgcc"
   1.224 -    else
   1.225 -        libgcc_rule="libgcc.mk"
   1.226 -        build_rules="all-gcc"
   1.227 -        install_rules="install-gcc"
   1.228 -    fi
   1.229 -
   1.230 -    CT_DoExecLog ALL make ${PARALLELMFLAGS} -C gcc ${libgcc_rule}
   1.231 -    sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
   1.232 -
   1.233 -    if [ "${CT_CANADIAN}" = "y" ]; then
   1.234 -        CT_DoLog EXTRA "Building libiberty"
   1.235 -        CT_DoExecLog ALL make ${PARALLELMFLAGS} all-build-libiberty
   1.236 -    fi
   1.237 -
   1.238 -    CT_DoLog EXTRA "Building shared core C compiler"
   1.239 -    CT_DoExecLog ALL make ${PARALLELMFLAGS} ${build_rules}
   1.240 -
   1.241 -    CT_DoLog EXTRA "Installing shared core C compiler"
   1.242 +    CT_DoLog EXTRA "Installing ${mode} core C compiler"
   1.243      CT_DoExecLog ALL make ${install_rules}
   1.244  
   1.245      CT_EndStep