scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jan 03 22:57:25 2012 +0100 (2012-01-03)
changeset 2936 2dfea349d307
parent 2544 751c3f735ada
child 3044 c79d55b27724
permissions -rw-r--r--
cc/gcc: build core compilers for canadian

Currently, we rely on an existing external cross-compiler targetting
the target, to build the C library.

This can pause quite a few problems if that compiler is different from
the one we are building, because it could introduce some ABI issues.

This patch removes this dependency, by building the core compilers
as we do for standard cross, and also by building the binutils and
gcc, for running on the build machine.

This means we no longer need to offer the cross-sompiler selection in
the menuconfig.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 # This file contains crosstool-NG internal steps
     2 
     3 # This step is called once all components were built, to remove
     4 # un-wanted files, to add tuple aliases, and to add the final
     5 # crosstool-NG-provided files.
     6 do_finish() {
     7     local _t
     8     local _type
     9     local strip_args
    10     local gcc_version
    11 
    12     CT_DoStep INFO "Cleaning-up the toolchain's directory"
    13 
    14     if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
    15         case "$CT_HOST" in
    16             *darwin*)
    17                 strip_args=""
    18                 ;;
    19             *)
    20                 strip_args="--strip-all -v"
    21                 ;;
    22         esac
    23         CT_DoLog INFO "Stripping all toolchain executables"
    24         CT_Pushd "${CT_PREFIX_DIR}"
    25         # We can not use the version in CT_CC_VERSION because
    26         # of the Linaro stuff. So, harvest the version string
    27         # directly from the gcc sources...
    28         # All gcc 4.x seem to have the version in gcc/BASE-VER
    29         # while version prior to 4.x have the version in gcc/version.c
    30         # Of course, here is not the better place to do that...
    31         if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
    32             gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
    33         else
    34             gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
    35                                "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c"   \
    36                          )
    37         fi
    38         for _t in "bin/${CT_TARGET}-"*                                      \
    39                   "${CT_TARGET}/bin/"*                                      \
    40                   "libexec/gcc/${CT_TARGET}/${gcc_version}/"*               \
    41                   "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \
    42         ; do
    43             _type="$( file "${_t}" |cut -d ' ' -f 2- )"
    44             case "${_type}" in
    45                 *script*executable*)
    46                     ;;
    47                 *executable*)
    48                     CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
    49                     ;;
    50             esac
    51         done
    52         CT_Popd
    53     fi
    54 
    55     if [ "${CT_BARE_METAL}" != "y" ]; then
    56         CT_DoLog EXTRA "Installing the populate helper"
    57         sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
    58                -e 's|@@CT_install@@|'"${install}"'|g;'  \
    59                -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
    60                -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
    61                -e 's|@@CT_make@@|'"${make}"'|g;'        \
    62                -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
    63                "${CT_LIB_DIR}/scripts/populate.in"      \
    64                >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    65         CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    66     fi
    67 
    68     if [ "${CT_LIBC_XLDD}" = "y" ]; then
    69         CT_DoLog EXTRA "Installing a cross-ldd helper"
    70         sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;'   \
    71                -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;'     \
    72                -e 's|@@CT_BITS@@|'"${CT_ARCH_BITNESS}"'|g;' \
    73                -e 's|@@CT_install@@|'"${install}"'|g;'      \
    74                -e 's|@@CT_bash@@|'"${bash}"'|g;'            \
    75                -e 's|@@CT_grep@@|'"${grep}"'|g;'            \
    76                -e 's|@@CT_make@@|'"${make}"'|g;'            \
    77                -e 's|@@CT_sed@@|'"${sed}"'|g;'              \
    78                "${CT_LIB_DIR}/scripts/xldd.in"              \
    79                >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
    80         CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
    81     fi
    82 
    83     # Create the aliases to the target tools
    84     CT_DoLog EXTRA "Creating toolchain aliases"
    85     CT_Pushd "${CT_PREFIX_DIR}/bin"
    86     for t in "${CT_TARGET}-"*; do
    87         if [ -n "${CT_TARGET_ALIAS}" ]; then
    88             _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
    89             CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
    90         fi
    91         if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
    92             _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
    93             if [ "${_t}" = "${t}" ]; then
    94                 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
    95             else
    96                 CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
    97             fi
    98         fi
    99     done
   100     CT_Popd
   101 
   102     CT_DoLog EXTRA "Removing access to the build system tools"
   103     CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
   104 
   105     # Remove the generated documentation files
   106     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   107         CT_DoLog EXTRA "Removing installed documentation"
   108         CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info}
   109         CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info}
   110         CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
   111     fi
   112 
   113     # Remove the lib* symlinks, now:
   114     # The symlinks are needed only during the build process.
   115     # The final gcc will still search those dirs, but will also search
   116     # the standard lib/ dirs, so we can get rid of the symlinks
   117     CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/lib32"
   118     CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/lib64"
   119 
   120     CT_EndStep
   121 }