Further improve the architecture-specific framework.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Sep 15 21:44:18 2007 +0000 (2007-09-15)
changeset 39111172b754564
parent 390 eb3b271ca27c
child 392 ee71450c5a6f
Further improve the architecture-specific framework.
Apply this framework into building of glibc and gcc.

(Whoo! 500th commit! Yeah!)
docs/overview.txt
scripts/build/cc_gcc.sh
scripts/build/libc_glibc.sh
scripts/crosstool.sh
scripts/functions
     1.1 --- a/docs/overview.txt	Sat Sep 15 08:40:07 2007 +0000
     1.2 +++ b/docs/overview.txt	Sat Sep 15 21:44:18 2007 +0000
     1.3 @@ -493,24 +493,15 @@
     1.4          the endianness suffixes
     1.5     + return value: 0 upon success, !0 upon failure
     1.6     + provides:
     1.7 -     - the environment variable CT_KERNEL_ARCH
     1.8 -     - optional
     1.9 -     - contains:
    1.10 -       the architecture name as understandable by the Linux kernel build
    1.11 -       system.
    1.12 -       Eg.: "arm" for an ARM
    1.13 -            "powerpc" for a PowerPC
    1.14 -            "i386" for an x86
    1.15 -   + provides:
    1.16 +     - mandatory
    1.17       - the environment variable CT_TARGET_ARCH
    1.18 -     - mandatory
    1.19       - contains:
    1.20         the architecture part of the target tuple.
    1.21         Eg.: "armeb" for big endian ARM
    1.22              "i386" for an i386
    1.23     + provides:
    1.24 +     - optional
    1.25       - the environment variable CT_TARGET_SYS
    1.26 -     - optional
    1.27       - contain:
    1.28         the sytem part of the target tuple.
    1.29         Eg.: "gnu" for glibc on most architectures
    1.30 @@ -519,17 +510,53 @@
    1.31         - for glibc-based toolchain: "gnu"
    1.32         - for uClibc-based toolchain: "uclibc"
    1.33     + provides:
    1.34 -     - the environment variable CT_ARCH_ENDIAN_OPT
    1.35       - optional
    1.36 +     - the environment variable CT_KERNEL_ARCH
    1.37       - contains:
    1.38 -       the compiler option to set the endianness.
    1.39 -       Eg.: "-ml" for a Super-H little endian
    1.40 -            "-mbig-endian" for an ARM big endian
    1.41 -            /empty/ for x86 and x86_64
    1.42 +       the architecture name as understandable by the Linux kernel build
    1.43 +       system.
    1.44 +       Eg.: "arm" for an ARM
    1.45 +            "powerpc" for a PowerPC
    1.46 +            "i386" for an x86
    1.47       - defaults to:
    1.48 -       - for bi-endian big endian architectures: "-mbig-endian"
    1.49 -       - for bi-endian little endian architectures: "-mlittle-endian"
    1.50 -       - for single-endian architectures: /empty/
    1.51 +       ${CT_ARCH}
    1.52 +   + provides:
    1.53 +     - optional
    1.54 +     - the environment variables to configure the cross-gcc
    1.55 +       - CT_ARCH_WITH_ARCH
    1.56 +       - CT_ARCH_WITH_ABI
    1.57 +       - CT_ARCH_WITH_CPU
    1.58 +       - CT_ARCH_WITH_TUNE
    1.59 +       - CT_ARCH_WITH_FPU
    1.60 +       - CT_ARCH_WITH_FLOAT
    1.61 +     - contain (defaults):
    1.62 +       - CT_ARCH_WITH_ARCH    : the gcc ./configure switch to select architecture level         ( "--with-arch=${CT_ARCH_ARCH}"       )
    1.63 +       - CT_ARCH_WITH_ABI     : the gcc ./configure switch to select ABI level                  ( "--with-abi=${CT_ARCH_ARCH}"        )
    1.64 +       - CT_ARCH_WITH_CPU     : the gcc ./configure switch to select CPU instruction set        ( "--with-cpu=${CT_ARCH_ARCH}"        )
    1.65 +       - CT_ARCH_WITH_TUNE    : the gcc ./configure switch to select scheduling                 ( "--with-tune=${CT_ARCH_ARCH}"       )
    1.66 +       - CT_ARCH_WITH_FPU     : the gcc ./configure switch to select FPU type                   ( "--with-fpu=${CT_ARCH_ARCH}"        )
    1.67 +       - CT_ARCH_WITH_FLOAT   : the gcc ./configure switch to select floating point arithmetics ( "--with-float=soft" or /empty/      )
    1.68 +   + provides:
    1.69 +     - optional
    1.70 +     - the environment variables to pass to the cross-gcc to build target binaries
    1.71 +       - CT_ARCH_ARCH_CFLAG
    1.72 +       - CT_ARCH_ABI_CFLAG
    1.73 +       - CT_ARCH_CPU_CFLAG
    1.74 +       - CT_ARCH_TUNE_CFLAG
    1.75 +       - CT_ARCH_FPU_CFLAG
    1.76 +       - CT_ARCH_FLOAT_CFLAG
    1.77 +       - CT_ARCH_ENDIAN_CFLAG
    1.78 +     - contain (defaults):
    1.79 +       - CT_ARCH_ARCH_CFLAG   : the gcc switch to select architecture level                     ( "-march=${CT_ARCH_ARCH}"            )
    1.80 +       - CT_ARCH_ABI_CFLAG    : the gcc switch to select ABI level                              ( "-mabi=${CT_ARCH_AABI}"             )
    1.81 +       - CT_ARCH_CPU_CFLAG    : the gcc switch to select CPU instruction set                    ( "-mcpu=${CT_ARCH_CPU}"              )
    1.82 +       - CT_ARCH_TUNE_CFLAG   : the gcc switch to select scheduling                             ( "-mtune=${CT_ARCH_TUNE}"            )
    1.83 +       - CT_ARCH_FPU_CFLAG    : the gcc switch to select FPU type                               ( "-mfpu=${CT_ARCH_FPU}"              )
    1.84 +       - CT_ARCH_FLOAT_CFLAG  : the gcc switch to choose floating point arithmetics             ( "-msoft-float" or /empty/           )
    1.85 +       - CT_ARCH_ENDIAN_CFLAG : the gcc switch to choose big or little endian                   ( "-mbig-endian" or "-mlittle-endian" )
    1.86 +     - default to:
    1.87 +       see above.
    1.88 +     
    1.89  
    1.90  Build scripts |
    1.91  --------------*
     2.1 --- a/scripts/build/cc_gcc.sh	Sat Sep 15 08:40:07 2007 +0000
     2.2 +++ b/scripts/build/cc_gcc.sh	Sat Sep 15 21:44:18 2007 +0000
     2.3 @@ -65,13 +65,7 @@
     2.4  
     2.5      CT_DoLog EXTRA "Configuring static core C compiler"
     2.6  
     2.7 -    extra_config=""
     2.8 -    [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
     2.9 -    [ -n "${CT_ARCH_ABI}" ]  && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
    2.10 -    [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
    2.11 -    [ -n "${CT_ARCH_CPU}" ]  && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
    2.12 -    [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
    2.13 -    [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
    2.14 +    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}"
    2.15      [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
    2.16  
    2.17      CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
    2.18 @@ -123,13 +117,7 @@
    2.19  
    2.20      CT_DoLog EXTRA "Configuring shared core C compiler"
    2.21  
    2.22 -    extra_config=""
    2.23 -    [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
    2.24 -    [ -n "${CT_ARCH_ABI}" ]  && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
    2.25 -    [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
    2.26 -    [ -n "${CT_ARCH_CPU}" ]  && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
    2.27 -    [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
    2.28 -    [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
    2.29 +    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}"
    2.30      [ "${CT_CC_CXA_ATEXIT}" = "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
    2.31  
    2.32      CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
    2.33 @@ -228,18 +216,8 @@
    2.34      lang_opt=`echo "${lang_opt},${CT_CC_LANG_OTHERS}" |sed -r -e 's/,+/,/g; s/,*$//;'`
    2.35  
    2.36      extra_config="--enable-languages=${lang_opt}"
    2.37 -    [ "${CT_ARCH_FLOAT_SW}" = "y" ] && extra_config="${extra_config} --with-float=soft"
    2.38 +    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}"
    2.39      [ "${CT_SHARED_LIBS}" = "y" ] || extra_config="${extra_config} --disable-shared"
    2.40 -    [ -n "${CT_ARCH_ABI}" ]  && extra_config="${extra_config} --with-abi=${CT_ARCH_ABI}"
    2.41 -    [ -n "${CT_ARCH_CPU}" ]  && extra_config="${extra_config} --with-cpu=${CT_ARCH_CPU}"
    2.42 -    [ -n "${CT_ARCH_TUNE}" ] && extra_config="${extra_config} --with-tune=${CT_ARCH_TUNE}"
    2.43 -    [ -n "${CT_ARCH_ARCH}" ] && extra_config="${extra_config} --with-arch=${CT_ARCH_ARCH}"
    2.44 -    [ -n "${CT_ARCH_FPU}" ] && extra_config="${extra_config} --with-fpu=${CT_ARCH_FPU}"
    2.45 -    if [ "${CT_TARGET_MULTILIB}" = "y" ]; then
    2.46 -       extra_config="${extra_config} --enable-multilib"
    2.47 -    else
    2.48 -       extra_config="${extra_config} --disable-multilib"
    2.49 -    fi
    2.50      [ "${CT_CC_CXA_ATEXIT}" == "y" ] && extra_config="${extra_config} --enable-__cxa_atexit"
    2.51  
    2.52      CT_DoLog DEBUG "Extra config passed: \"${extra_config}\""
    2.53 @@ -268,7 +246,6 @@
    2.54          make ${PARALLELMFLAGS} all-build-libiberty 2>&1 |CT_DoLog ALL
    2.55      fi
    2.56  
    2.57 -
    2.58      # Idea from <cort.dougan at gmail.com>:
    2.59      # Fix lib/lib64 confusion for GCC 3.3.3 on PowerPC64 and x86_64.
    2.60      # GCC 3.4.0 and up don't suffer from this confusion, and don't need this
     3.1 --- a/scripts/build/libc_glibc.sh	Sat Sep 15 08:40:07 2007 +0000
     3.2 +++ b/scripts/build/libc_glibc.sh	Sat Sep 15 21:44:18 2007 +0000
     3.3 @@ -155,7 +155,7 @@
     3.4      case "${CT_THREADS}" in
     3.5          nptl)
     3.6              # NOTE: for some archs, the pathes are different, but they are not
     3.7 -            # supported by ct-ng right now. See original crosstool when they are.
     3.8 +            # supported by crosstool-NG right now. See original crosstool when they are.
     3.9              pthread_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/${CT_THREADS}/sysdeps/pthread/pthread.h"
    3.10              pthreadtypes_h="${CT_SRC_DIR}/${CT_LIBC_FILE}/nptl/sysdeps/unix/sysv/linux/${CT_KERNEL_ARCH}/bits/pthreadtypes.h"
    3.11              if [ ! -f "${pthreadtypes_h}" ]; then
    3.12 @@ -206,13 +206,9 @@
    3.13          y) extra_config="${extra_config} --enable-shared";;
    3.14          *) extra_config="${extra_config} --disable-shared";;
    3.15      esac
    3.16 -    case "${CT_LIBC_GLIBC_EXTRA_CONFIG}" in
    3.17 -        *--with-fp*) ;;
    3.18 -        *--without-fp*) ;;
    3.19 -        *)  case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
    3.20 -                y,) extra_config="${extra_config} --with-fp";;
    3.21 -                ,y) extra_config="${extra_config} --without-fp";;
    3.22 -            esac;;
    3.23 +    case "${CT_ARCH_FLOAT_HW},${CT_ARCH_FLOAT_SW}" in
    3.24 +        y,) extra_config="${extra_config} --with-fp";;
    3.25 +        ,y) extra_config="${extra_config} --without-fp";;
    3.26      esac
    3.27      # Obviously, we want threads, as we come here only for NPTL
    3.28      extra_config="${extra_config} --with-__thread"
    3.29 @@ -238,8 +234,9 @@
    3.30      CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
    3.31      CT_DoLog DEBUG "Extra CC args passed    : \"${extra_cc_args}\""
    3.32  
    3.33 -    # sh3 and sh4 really need to set configparms as of gcc-3.4/glibc-2.3.2
    3.34 -    # note: this is awkward, doesn't work well if you need more than one line in configparms
    3.35 +    # Super-H really needs to set configparms as of gcc-3.4/glibc-2.3.2
    3.36 +    # note: this is awkward, doesn't work well if you need more than one
    3.37 +    # line in configparms
    3.38      echo ${CT_LIBC_GLIBC_CONFIGPARMS} > configparms
    3.39  
    3.40      echo "libc_cv_forced_unwind=yes" > config.cache
     4.1 --- a/scripts/crosstool.sh	Sat Sep 15 08:40:07 2007 +0000
     4.2 +++ b/scripts/crosstool.sh	Sat Sep 15 21:44:18 2007 +0000
     4.3 @@ -301,13 +301,6 @@
     4.4          fi |CT_DoLog DEBUG
     4.5      done
     4.6  
     4.7 -    # Build up the TARGET_CFLAGS from user-provided options
     4.8 -    # Override with user-specified CFLAGS
     4.9 -    [ -n "${CT_ARCH_CPU}" ]  && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
    4.10 -    [ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
    4.11 -    [ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
    4.12 -    [ -n "${CT_ARCH_FPU}" ]  && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
    4.13 -
    4.14      # Help gcc
    4.15      CT_CFLAGS_FOR_HOST=
    4.16      [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
     5.1 --- a/scripts/functions	Sat Sep 15 08:40:07 2007 +0000
     5.2 +++ b/scripts/functions	Sat Sep 15 21:44:18 2007 +0000
     5.3 @@ -491,11 +491,11 @@
     5.4      case "${CT_ARCH_BE},${CT_ARCH_LE}" in
     5.5          y,) target_endian_eb=eb
     5.6              target_endian_el=
     5.7 -            CT_ARCH_ENDIAN_OPT="-mbig-endian"
     5.8 +            CT_ARCH_ENDIAN_CFLAG="-mbig-endian"
     5.9              ;;
    5.10          ,y) target_endian_eb=
    5.11              target_endian_el=el
    5.12 -            CT_ARCH_ENDIAN_OPT="-mlittle-endian"
    5.13 +            CT_ARCH_ENDIAN_CFLAG="-mlittle-endian"
    5.14              ;;
    5.15      esac
    5.16  
    5.17 @@ -509,13 +509,32 @@
    5.18      # Transform the ARCH into a kernel-understandable ARCH
    5.19      CT_KERNEL_ARCH="${CT_ARCH}"
    5.20  
    5.21 +    # Set the default values for ARCH, ABI, CPU, TUNE, FPU and FLOAT
    5.22 +    unset CT_ARCH_ARCH_CFLAG CT_ARCH_ABI_CFLAG CT_ARCH_CPU_CFLAG CT_ARCH_TUNE_CFLAG CT_ARCH_FPU_CFLAG
    5.23 +    unset CT_ARCH_WITH_ARCH CT_ARCH_WITH_ABI CT_ARCH_WITH_CPU CT_ARCH_WITH_TUNE CT_ARCH_WITH_FPU
    5.24 +    [ "${CT_ARCH_ARCH}"     ] && { CT_ARCH_ARCH_CFLAG="-march=${CT_ARCH_ARCH}";  CT_ARCH_WITH_ARCH="--with-arch=${CT_ARCH_ARCH}"; }
    5.25 +    [ "${CT_ARCH_ABI}"      ] && { CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_ABI}";     CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_ABI}";    }
    5.26 +    [ "${CT_ARCH_CPU}"      ] && { CT_ARCH_CPU_CFLAG="-mcpu=${CT_ARCH_CPU}";     CT_ARCH_WITH_CPU="--with-cpu=${CT_ARCH_CPU}";    }
    5.27 +    [ "${CT_ARCH_TUNE}"     ] && { CT_ARCH_TUNE_CFLAG="-march=${CT_ARCH_TUNE}";  CT_ARCH_WITH_TUNE="--with-tune=${CT_ARCH_TUNE}"; }
    5.28 +    [ "${CT_ARCH_FPU}"      ] && { CT_ARCH_FPU_CFLAG="-mfpu=${CT_ARCH_FPU}";     CT_ARCH_WITH_FPU="--with-fpu=${CT_ARCH_FPU}";    }
    5.29 +    [ "${CT_ARCH_FLOAT_SW}" ] && { CT_ARCH_FPU_CFLAG="-msoft-float";             CT_ARCH_WITH_FLOAT="--with-float=soft";          }
    5.30 +
    5.31      # Call the architecture specific settings
    5.32      CT_DoArchValues
    5.33  
    5.34 +    # Finish the target tuple construction
    5.35      case "${CT_KERNEL}" in
    5.36          linux*)  CT_TARGET_KERNEL=linux;;
    5.37      esac
    5.38      CT_TARGET=`CT_DoConfigSub "${CT_TARGET_ARCH}-${CT_TARGET_VENDOR:-unknown}-${CT_TARGET_KERNEL}-${CT_TARGET_SYS}"`
    5.39 +
    5.40 +    # Prepare the target CFLAGS
    5.41 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_ARCH_CFLAGS}"
    5.42 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_ABI_CFLAGS}"
    5.43 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_CPU_CFLAGS}"
    5.44 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_TUNE_CFLAGS}"
    5.45 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_FPU_CFLAGS}"
    5.46 +    CT_TARGET_CFLAGS="${CT_TARGET_CFLAGS} ${CT_ARCH_FLOAT_CFLAGS}"
    5.47  }
    5.48  
    5.49  # This function does pause the build until the user strikes "Return"