Patchwork [1,of,1] cc/gcc: Split gcc configurations and functions from cc ones

login
register
mail settings
Submitter Yann Diorcet
Date Dec. 11, 2013, 8:41 p.m.
Message ID <cc545a5c18967b99bb58.1386794508@blackmint>
Download mbox | patch
Permalink /patch/300411/
State New
Headers show

Comments

Yann Diorcet - Dec. 11, 2013, 8:41 p.m.
# HG changeset patch
# User Yann Diorcet <diorcet.yann@gmail.com>
# Date 1386793717 -3600
#      Wed Dec 11 21:28:37 2013 +0100
# Node ID cc545a5c18967b99bb58e57bef03471254eb9745
# Parent  7e569a9cb5fd3ab591bb307328b947a5b7312cba
cc/gcc: Split gcc configurations and functions from cc ones

Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com>


--
For unsubscribe information see http://sourceware.org/lists.html#faq
Yann E. MORIN - Dec. 12, 2013, 10:07 p.m.
Yann, All,

On 2013-12-11 21:41 +0100, Yann Diorcet spake thusly:
> # HG changeset patch
> # User Yann Diorcet <diorcet.yann@gmail.com>
> # Date 1386793717 -3600
> #      Wed Dec 11 21:28:37 2013 +0100
> # Node ID cc545a5c18967b99bb58e57bef03471254eb9745
> # Parent  7e569a9cb5fd3ab591bb307328b947a5b7312cba
> cc/gcc: Split gcc configurations and functions from cc ones
> 
> Signed-off-by: Yann Diorcet <diorcet.yann@gmail.com>
> 
> diff -r 7e569a9cb5fd -r cc545a5c1896 config/cc.in
> --- a/config/cc.in	Sat Nov 16 18:14:45 2013 +0100
> +++ b/config/cc.in	Wed Dec 11 21:28:37 2013 +0100
> @@ -4,9 +4,7 @@
>  
>  config CC
>      string
> -
> -config CC_VERSION
> -    string
> +    default "gcc"

This should have gone in config/cc/gcc.in itself, as:

    config CC
        default "gcc"

I'll do the change locally, no need to resend.

[--SNIP--]
> diff -r 7e569a9cb5fd -r cc545a5c1896 config/config.mk
> --- a/config/config.mk	Sat Nov 16 18:14:45 2013 +0100
> +++ b/config/config.mk	Wed Dec 11 21:28:37 2013 +0100
> @@ -83,7 +83,7 @@
>  
>  config.gen/cc.in: $(CC_CONFIG_FILES) $(CC_CONFIG_FILES_2)
>  	@$(ECHO) '  IN    $(@)'
> -	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C compiler" "CC" "config/cc" "N" $(CCS)
> +	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh menu "$@" "C compiler" "CC" "config/cc" $(CCS)

With this change, it is now possible to generate invalid configurations,
where no C compiler is selected. This is Not Good (TM).

Why do you need that?

[--SNIP--]
> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/cc.sh
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/scripts/build/cc.sh	Wed Dec 11 21:28:37 2013 +0100
> @@ -0,0 +1,59 @@
> +# Wrapper to build the companion tools facilities

s/companion tools facilities/C compiler components/

Yet, this be a separate patch. Please do only one semantic change per
patch, that is:
  - one patch to rename the config options
  - a second patch to change the config opitons (can be folded in the
    previous patch, but separate helps do the review)
  - a third patch to introduce this wrapper
  - and so on...

I must say I do not like this wrapper: why can you handle the llvm and
clang stuff as another compiler, on-par with gcc?

The wrapper for the companion tools is needed because we do not have
proper dependency tracking about the order the components are to be
built.

[--SNIP--]
> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/debug/300-gdb.sh
> --- a/scripts/build/debug/300-gdb.sh	Sat Nov 16 18:14:45 2013 +0100
> +++ b/scripts/build/debug/300-gdb.sh	Wed Dec 11 21:28:37 2013 +0100
> @@ -181,11 +181,11 @@
>          if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then
>              CT_DoLog EXTRA "Installing '.gdbinit' template"
>              # See in scripts/build/internals.sh for why we do this
> -            if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
> -                gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
> +            if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
> +                gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
>              else
> -                gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
> -                                   "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c"   \
> +                gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;'     \
> +                                   "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c"   \
>                               )
>              fi

This whole if-else-fi block should be conditional to gcc being selected,
in the end, since otherwise the ele-part will fail. Like you did below,
BTW...

[--SNIP--]
> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/internals.sh
> --- a/scripts/build/internals.sh	Sat Nov 16 18:14:45 2013 +0100
> +++ b/scripts/build/internals.sh	Wed Dec 11 21:28:37 2013 +0100
> @@ -28,33 +28,35 @@
>              CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args}         \
>                               "${CT_TARGET}/debug-root/usr/bin/gdbserver"
>          fi
> -        # We can not use the version in CT_CC_VERSION because
> -        # of the Linaro stuff. So, harvest the version string
> -        # directly from the gcc sources...
> -        # All gcc 4.x seem to have the version in gcc/BASE-VER
> -        # while version prior to 4.x have the version in gcc/version.c
> -        # Of course, here is not the better place to do that...
> -        if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
> -            gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
> -        else
> -            gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
> -                               "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c"   \
> -                         )
> +        if [ "${CT_CC_gcc}" = "y" ]; then

... here.

[--SNIP--]
> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/crosstool-NG.sh.in
> --- a/scripts/crosstool-NG.sh.in	Sat Nov 16 18:14:45 2013 +0100
> +++ b/scripts/crosstool-NG.sh.in	Wed Dec 11 21:28:37 2013 +0100
[--SNIP--]
> @@ -162,8 +162,8 @@
>  # Put user-supplied flags at the end, so that they take precedence.
>  CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
>  CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
> -CT_CC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
> -CT_CC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_EXTRA_CONFIG_ARRAY[@]}" )
> +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
> +CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" )

Maybe now would be the proper time to move that into gcc.sh?

>  # Compute the package version string
>  CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}"
> @@ -545,8 +545,8 @@
>          CT_EndStep
>      fi
>  
> -    if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
> -        CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_STATIC_LIBSTDCXX)"
> +    if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
> +        CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_GCC_STATIC_LIBSTDCXX)"
>          CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system"
>          CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -lstdc++ -o "${gccout}"
>          rm -f "${gccout}"

And move this block in gcc.sh, too.

This would require a new step before cc_extract. Like we have
libc_check_config, we could introduce cc_check_config that would do this
static link test.

> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/gen_in_frags.sh
> --- a/scripts/gen_in_frags.sh	Sat Nov 16 18:14:45 2013 +0100
> +++ b/scripts/gen_in_frags.sh	Wed Dec 11 21:28:37 2013 +0100
> @@ -138,6 +138,9 @@
>          _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
>          printf 'menuconfig %s_%s\n' "${cfg_prefix}" "${_entry}"
>          printf '    bool\n'
> +        if "${grep}" -E '^## default' ${file} >/dev/null 2>&1; then
> +            "${sed}" -r -e '/^## default ?/!d; s/^## default ?/    default /;' ${file} 2>/dev/null
> +        fi

This should also go into a separate patch: it adds yet _another_ new
feature.

Typically, this could go as the first patch in a series: since this is
very simple, it can be reviewed very easily and applied quickly*.

[*] yes, 'quickly' can be very relative, sorry... :-/

>          printf '    prompt "%s"\n' "${entry}"
>          "${sed}" -r -e '/^## depends on /!d; s/^## /    /;' ${file} 2>/dev/null
>          "${sed}" -r -e '/^## select /!d; s/^## /    /;' ${file} 2>/dev/null
> diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/showSamples.sh
> --- a/scripts/showSamples.sh	Sat Nov 16 18:14:45 2013 +0100
> +++ b/scripts/showSamples.sh	Wed Dec 11 21:28:37 2013 +0100
> @@ -76,16 +76,24 @@
>              [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s"    "${CT_LIBELF_VERSION}"
>              [ -z "${complibs}"  ] || printf "\n"
>              printf  "    %-*s : %s\n" ${width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
> -            printf  "    %-*s : %s" ${width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
> -            [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
> -            [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
> -            [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
> -            [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
> -            [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
> -            [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
> -            [ "${CT_CC_LANG_GOLANG}" = "y"  ] && printf ",Go"
> -            [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
> -            printf ")\n"
> +            printf  "    %-*s :" ${width} "C compilers"
> +            for cc in $(compgen -A variable | sed -n 's/^CT_CC_\([^_]\+\)_VERSION$/\1/p'); do
> +                cc_variable=CT_CC_${cc}_VERSION
> +                version=${!cc_variable}
> +                compiler=$(echo $cc | sed -E ''| awk '{print tolower($0)}')
> +                printf " $compiler-$version"
> +            done
> +            printf "\n"
> +            printf  "    %-*s : %s" ${width} "Languages" "C"
> +            [ "${CT_CC_LANG_CXX}" = "y"     ] && printf " C++"
> +            [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf " Fortran"
> +            [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf " Java"
> +            [ "${CT_CC_LANG_ADA}" = "y"     ] && printf " ADA"
> +            [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf " Objective-C"
> +            [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf " Objective-C++"
> +            [ "${CT_CC_LANG_GOLANG}" = "y"  ] && printf " Go"
> +            [ -n "${CT_CC_LANG_OTHERS}"     ] && printf " ${CT_CC_LANG_OTHERS}"

Here, you're again doing two unrelated changes:
  - one to replace commas with spaces (to match the tools, below: good)
  - one to introduce the compilers list


Really, I can't see the whole picture of all this work.

By splitting the changes into independent, self-contained patches, it's
like if you were telling a story: a patch series is a scenario, with each
change being a chapter. Then, writing a series is like writing a book:

- first, the cover-letter: you state the overal goal of the series. A
  cover-letter can be very long if need be: you need to explain the
  intent, the issues you're trying to solve, why you decided to do
  things the way you've done them. Eg.:

    This series introduces the basis needed to add Darwin as a target.

    Darwin requires llvm and/or clang as a compiler. Thus we need to be
    able to build two or more different compilers in the same toolchain.

    So this series does:

    For that, we need to differentiate the current gcc-specific options;
    they are currently not tied to gcc, but are generic (eg. CT_CC_VERSION).
    --> patches 1, 2 and 3

    Then, we add clang, and then llvm, as two new C compilers.
    --> patches 4 to 9

    Finally, we make it possible to select more than one compiler. For
    this we need to change the current choice into a multi-select.
    --> patches 10 and 11

- then the individual patches: you explain more in details what each
  patch does. If it is not obvious why a patch exist, explain that it
  is a requirement for the next patch (eg. your '## default' does not
  look very useful by itself, but saying "needed to select more than one
  compiler, coming in a following patch, and still be able to have a
  default value" is very informative).


Again, I know Ray and you have put a lot of effort in this work. nd I
haven't been very reactive.

But the sheer amount of changes in this "simple preliminary" patch is
just overwhelming.

Please, be sure to reduce the changes as much as possible: if all the
above had been split into separate patches, it would have been easier to
review and apply.

Regards,
Yann E. MORIN.

Patch

diff -r 7e569a9cb5fd -r cc545a5c1896 config/cc.in
--- a/config/cc.in	Sat Nov 16 18:14:45 2013 +0100
+++ b/config/cc.in	Wed Dec 11 21:28:37 2013 +0100
@@ -4,9 +4,7 @@ 
 
 config CC
     string
-
-config CC_VERSION
-    string
+    default "gcc"
 
 config CC_CORE_PASSES_NEEDED
 	bool
@@ -126,6 +124,4 @@ 
 
 endif # ! BARE_METAL
 
-source "config.gen/cc.in.2"
-
 endmenu
diff -r 7e569a9cb5fd -r cc545a5c1896 config/cc/gcc.in
--- a/config/cc/gcc.in	Sat Nov 16 18:14:45 2013 +0100
+++ b/config/cc/gcc.in	Wed Dec 11 21:28:37 2013 +0100
@@ -1,5 +1,6 @@ 
 # Compiler options
 #
+## default y
 ## select CC_SUPPORT_CXX
 ## select CC_SUPPORT_FORTRAN
 ## select CC_SUPPORT_JAVA
@@ -36,215 +37,215 @@ 
 # Don't remove next line
 # CT_INSERT_VERSION_BELOW
 
-config CC_V_linaro_4_8
+config CC_GCC_V_linaro_4_8
     bool
     prompt "linaro-4.8-2013.06-1"
     depends on CC_GCC_SHOW_LINARO
     select CC_GCC_4_8
 
-config CC_V_4_8_2
+config CC_GCC_V_4_8_2
     bool
     prompt "4.8.2"
     select CC_GCC_4_8
 
-config CC_V_4_8_1
+config CC_GCC_V_4_8_1
     bool
     prompt "4.8.1"
     select CC_GCC_4_8
 
-config CC_V_4_8_0
+config CC_GCC_V_4_8_0
     bool
     prompt "4.8.0"
     select CC_GCC_4_8
 
-config CC_V_linaro_4_7
+config CC_GCC_V_linaro_4_7
     bool
     prompt "linaro-4.7-2013.06-1"
     depends on CC_GCC_SHOW_LINARO
     select CC_GCC_4_7
 
-config CC_V_4_7_3
+config CC_GCC_V_4_7_3
     bool
     prompt "4.7.3"
     select CC_GCC_4_7
 
-config CC_V_4_7_2
+config CC_GCC_V_4_7_2
     bool
     prompt "4.7.2"
     select CC_GCC_4_7
 
-config CC_V_4_7_1
+config CC_GCC_V_4_7_1
     bool
     prompt "4.7.1"
     select CC_GCC_4_7
 
-config CC_V_4_7_0
+config CC_GCC_V_4_7_0
     bool
     prompt "4.7.0"
     select CC_GCC_4_7
 
-config CC_V_linaro_4_6
+config CC_GCC_V_linaro_4_6
     bool
     prompt "linaro-4.6-2013.05"
     depends on CC_GCC_SHOW_LINARO
     select CC_GCC_4_6
 
-config CC_V_4_6_4
+config CC_GCC_V_4_6_4
     bool
     prompt "4.6.4"
     select CC_GCC_4_6
 
-config CC_V_4_6_3
+config CC_GCC_V_4_6_3
     bool
     prompt "4.6.3"
     select CC_GCC_4_6
 
-config CC_V_4_6_2
+config CC_GCC_V_4_6_2
     bool
     prompt "4.6.2"
     select CC_GCC_4_6
 
-config CC_V_4_6_1
+config CC_GCC_V_4_6_1
     bool
     prompt "4.6.1"
     select CC_GCC_4_6
 
-config CC_V_4_6_0
+config CC_GCC_V_4_6_0
     bool
     prompt "4.6.0"
     select CC_GCC_4_6
 
-config CC_V_linaro_4_5
+config CC_GCC_V_linaro_4_5
     bool
     prompt "linaro-4.5-2012.03"
     depends on CC_GCC_SHOW_LINARO
     select CC_GCC_4_5
 
-config CC_V_4_5_3
+config CC_GCC_V_4_5_3
     bool
     prompt "4.5.3"
     select CC_GCC_4_5
 
-config CC_V_4_5_2
+config CC_GCC_V_4_5_2
     bool
     prompt "4.5.2"
     select CC_GCC_4_5
 
-config CC_V_4_5_1
+config CC_GCC_V_4_5_1
     bool
     prompt "4.5.1"
     select CC_GCC_4_5
 
-config CC_V_4_5_0
+config CC_GCC_V_4_5_0
     bool
     prompt "4.5.0"
     select CC_GCC_4_5
 
 
-config CC_V_linaro_4_4
+config CC_GCC_V_linaro_4_4
     bool
     prompt "linaro-4.4-2011.02-0"
     depends on CC_GCC_SHOW_LINARO
     select CC_GCC_4_4
 
-config CC_V_4_4_7
+config CC_GCC_V_4_4_7
     bool
     prompt "4.4.7"
     select CC_GCC_4_4
 
-config CC_V_4_4_6
+config CC_GCC_V_4_4_6
     bool
     prompt "4.4.6"
     select CC_GCC_4_4
 
-config CC_V_4_4_5
+config CC_GCC_V_4_4_5
     bool
     prompt "4.4.5"
     select CC_GCC_4_4
 
-config CC_V_4_4_4
+config CC_GCC_V_4_4_4
     bool
     prompt "4.4.4"
     select CC_GCC_4_4
 
-config CC_V_4_4_3
+config CC_GCC_V_4_4_3
     bool
     prompt "4.4.3"
     select CC_GCC_4_4
 
-config CC_V_4_4_2
+config CC_GCC_V_4_4_2
     bool
     prompt "4.4.2"
     select CC_GCC_4_4
 
-config CC_V_4_4_1
+config CC_GCC_V_4_4_1
     bool
     prompt "4.4.1"
     select CC_GCC_4_4
 
-config CC_V_4_4_0
+config CC_GCC_V_4_4_0
     bool
     prompt "4.4.0"
     select CC_GCC_4_4
 
-config CC_V_4_3_6
+config CC_GCC_V_4_3_6
     bool
     prompt "4.3.6"
     select CC_GCC_4_3
 
-config CC_V_4_3_5
+config CC_GCC_V_4_3_5
     bool
     prompt "4.3.5"
     select CC_GCC_4_3
 
-config CC_V_4_3_4
+config CC_GCC_V_4_3_4
     bool
     prompt "4.3.4"
     select CC_GCC_4_3
 
-config CC_V_4_3_3
+config CC_GCC_V_4_3_3
     bool
     prompt "4.3.3"
     select CC_GCC_4_3
 
-config CC_V_4_3_2
+config CC_GCC_V_4_3_2
     bool
     prompt "4.3.2"
     select CC_GCC_4_3
 
-config CC_V_4_3_1
+config CC_GCC_V_4_3_1
     bool
     prompt "4.3.1"
     select CC_GCC_4_3
 
-config CC_V_4_2_4
+config CC_GCC_V_4_2_4
     bool
     prompt "4.2.4"
     select CC_GCC_4_2
 
 # We need that one, it's the only version with avr32 support
 # because we have a patch for it
-config CC_V_4_2_2
+config CC_GCC_V_4_2_2
     bool
     prompt "4.2.2"
     select CC_GCC_4_2
 
-config CC_V_4_1_2
+config CC_GCC_V_4_1_2
     bool
     prompt "4.1.2 (OBSOLETE)"
     depends on OBSOLETE
 
-config CC_V_4_0_4
+config CC_GCC_V_4_0_4
     bool
     prompt "4.0.4 (OBSOLETE)"
     depends on OBSOLETE
 
-config CC_V_3_4_6
+config CC_GCC_V_3_4_6
     bool
     prompt "3.4.6 (OBSOLETE)"
     depends on OBSOLETE
 
-config CC_CUSTOM
+config CC_GCC_CUSTOM
     bool
     prompt "Custom gcc"
     depends on EXPERIMENTAL
@@ -252,9 +253,9 @@ 
 
 endchoice
 
-if CC_CUSTOM
+if CC_GCC_CUSTOM
 
-config CC_CUSTOM_LOCATION
+config CC_GCC_CUSTOM_LOCATION
     string
     prompt "Full path to custom gcc source"
     default ""
@@ -262,7 +263,7 @@ 
       Enter the path to the directory (or tarball) of your source for gcc,
       or leave blank to use default CT_CUSTOM_LOCATION_ROOT_DIR/gcc
 
-endif #CC_CUSTOM
+endif #CC_GCC_CUSTOM
 
 config CC_GCC_4_2
     bool
@@ -434,6 +435,8 @@ 
     select GMP_NEEDED
     select MPFR_NEEDED
 
+    select CLOOG_NEEDED
+
 config CC_GCC_USE_MPC
     bool
     select MPC_NEEDED
@@ -445,52 +448,52 @@ 
 config CC_GCC_HAS_LIBQUADMATH
     bool
 
-config CC_VERSION
+config CC_GCC_VERSION
     string
 # Don't remove next line
 # CT_INSERT_VERSION_STRING_BELOW
-    default "linaro-4.8-2013.06-1" if CC_V_linaro_4_8
-    default "4.8.2" if CC_V_4_8_2
-    default "4.8.1" if CC_V_4_8_1
-    default "4.8.0" if CC_V_4_8_0
-    default "linaro-4.7-2013.06-1" if CC_V_linaro_4_7
-    default "4.7.3" if CC_V_4_7_3
-    default "4.7.2" if CC_V_4_7_2
-    default "4.7.1" if CC_V_4_7_1
-    default "4.7.0" if CC_V_4_7_0
-    default "linaro-4.6-2013.05" if CC_V_linaro_4_6
-    default "4.6.4" if CC_V_4_6_4
-    default "4.6.3" if CC_V_4_6_3
-    default "4.6.2" if CC_V_4_6_2
-    default "4.6.1" if CC_V_4_6_1
-    default "4.6.0" if CC_V_4_6_0
-    default "linaro-4.5-2012.03" if CC_V_linaro_4_5
-    default "4.5.3" if CC_V_4_5_3
-    default "4.5.2" if CC_V_4_5_2
-    default "4.5.1" if CC_V_4_5_1
-    default "4.5.0" if CC_V_4_5_0
-    default "linaro-4.4-2011.02-0" if CC_V_linaro_4_4
-    default "4.4.7" if CC_V_4_4_7
-    default "4.4.6" if CC_V_4_4_6
-    default "4.4.5" if CC_V_4_4_5
-    default "4.4.4" if CC_V_4_4_4
-    default "4.4.3" if CC_V_4_4_3
-    default "4.4.2" if CC_V_4_4_2
-    default "4.4.1" if CC_V_4_4_1
-    default "4.4.0" if CC_V_4_4_0
-    default "4.3.6" if CC_V_4_3_6
-    default "4.3.5" if CC_V_4_3_5
-    default "4.3.4" if CC_V_4_3_4
-    default "4.3.3" if CC_V_4_3_3
-    default "4.3.2" if CC_V_4_3_2
-    default "4.3.1" if CC_V_4_3_1
-    default "4.3.0" if CC_V_4_3_0
-    default "4.2.4" if CC_V_4_2_4
-    default "4.2.2" if CC_V_4_2_2
-    default "4.1.2" if CC_V_4_1_2
-    default "4.0.4" if CC_V_4_0_4
-    default "3.4.6" if CC_V_3_4_6
-    default "custom" if CC_CUSTOM
+    default "linaro-4.8-2013.06-1" if CC_GCC_V_linaro_4_8
+    default "4.8.2" if CC_GCC_V_4_8_2
+    default "4.8.1" if CC_GCC_V_4_8_1
+    default "4.8.0" if CC_GCC_V_4_8_0
+    default "linaro-4.7-2013.06-1" if CC_GCC_V_linaro_4_7
+    default "4.7.3" if CC_GCC_V_4_7_3
+    default "4.7.2" if CC_GCC_V_4_7_2
+    default "4.7.1" if CC_GCC_V_4_7_1
+    default "4.7.0" if CC_GCC_V_4_7_0
+    default "linaro-4.6-2013.05" if CC_GCC_V_linaro_4_6
+    default "4.6.4" if CC_GCC_V_4_6_4
+    default "4.6.3" if CC_GCC_V_4_6_3
+    default "4.6.2" if CC_GCC_V_4_6_2
+    default "4.6.1" if CC_GCC_V_4_6_1
+    default "4.6.0" if CC_GCC_V_4_6_0
+    default "linaro-4.5-2012.03" if CC_GCC_V_linaro_4_5
+    default "4.5.3" if CC_GCC_V_4_5_3
+    default "4.5.2" if CC_GCC_V_4_5_2
+    default "4.5.1" if CC_GCC_V_4_5_1
+    default "4.5.0" if CC_GCC_V_4_5_0
+    default "linaro-4.4-2011.02-0" if CC_GCC_V_linaro_4_4
+    default "4.4.7" if CC_GCC_V_4_4_7
+    default "4.4.6" if CC_GCC_V_4_4_6
+    default "4.4.5" if CC_GCC_V_4_4_5
+    default "4.4.4" if CC_GCC_V_4_4_4
+    default "4.4.3" if CC_GCC_V_4_4_3
+    default "4.4.2" if CC_GCC_V_4_4_2
+    default "4.4.1" if CC_GCC_V_4_4_1
+    default "4.4.0" if CC_GCC_V_4_4_0
+    default "4.3.6" if CC_GCC_V_4_3_6
+    default "4.3.5" if CC_GCC_V_4_3_5
+    default "4.3.4" if CC_GCC_V_4_3_4
+    default "4.3.3" if CC_GCC_V_4_3_3
+    default "4.3.2" if CC_GCC_V_4_3_2
+    default "4.3.1" if CC_GCC_V_4_3_1
+    default "4.3.0" if CC_GCC_V_4_3_0
+    default "4.2.4" if CC_GCC_V_4_2_4
+    default "4.2.2" if CC_GCC_V_4_2_2
+    default "4.1.2" if CC_GCC_V_4_1_2
+    default "4.0.4" if CC_GCC_V_4_0_4
+    default "3.4.6" if CC_GCC_V_3_4_6
+    default "custom" if CC_GCC_CUSTOM
 
 config CC_LANG_JAVA_USE_ECJ
     bool
@@ -501,3 +504,5 @@ 
 # Fortran always requires GMP+MPFR, whatever the gcc version
 config CC_LANG_FORTRAN
     select CC_GCC_USE_GMP_MPFR
+
+source "config/cc/gcc.in.2"
diff -r 7e569a9cb5fd -r cc545a5c1896 config/cc/gcc.in.2
--- a/config/cc/gcc.in.2	Sat Nov 16 18:14:45 2013 +0100
+++ b/config/cc/gcc.in.2	Wed Dec 11 21:28:37 2013 +0100
@@ -1,6 +1,6 @@ 
 # gcc configuration options
 
-config CC_ENABLE_CXX_FLAGS
+config CC_GCC_ENABLE_CXX_FLAGS
     string
     prompt "Flags to pass to --enable-cxx-flags"
     default ""
@@ -11,7 +11,7 @@ 
       Note: just pass in the option _value_, that is only the part that goes
       after the '=' sign.
 
-config CC_CORE_EXTRA_CONFIG_ARRAY
+config CC_GCC_CORE_EXTRA_CONFIG_ARRAY
     string
     prompt "Core gcc extra config"
     default ""
@@ -25,7 +25,7 @@ 
       if they are properly quoted (or escaped, but prefer quotes). Eg.:
           --with-foo="1st arg with 4 spaces" --with-bar=2nd-arg-without-space
 
-config CC_EXTRA_CONFIG_ARRAY
+config CC_GCC_EXTRA_CONFIG_ARRAY
     string
     prompt "gcc extra config"
     default ""
@@ -38,9 +38,9 @@ 
           --with-foo="1st arg with 4 spaces" --with-bar=2nd-arg-without-space
 
 config STATIC_TOOLCHAIN
-    select CC_STATIC_LIBSTDCXX if CC_GCC_4_4_or_later
+    select CC_GCC_STATIC_LIBSTDCXX if CC_GCC_4_4_or_later
 
-config CC_STATIC_LIBSTDCXX
+config CC_GCC_STATIC_LIBSTDCXX
     bool
     prompt "Link libstdc++ statically into the gcc binary"
     default y
diff -r 7e569a9cb5fd -r cc545a5c1896 config/config.mk
--- a/config/config.mk	Sat Nov 16 18:14:45 2013 +0100
+++ b/config/config.mk	Wed Dec 11 21:28:37 2013 +0100
@@ -83,7 +83,7 @@ 
 
 config.gen/cc.in: $(CC_CONFIG_FILES) $(CC_CONFIG_FILES_2)
 	@$(ECHO) '  IN    $(@)'
-	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C compiler" "CC" "config/cc" "N" $(CCS)
+	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh menu "$@" "C compiler" "CC" "config/cc" $(CCS)
 
 config.gen/binutils.in: $(CC_BINUTILS_FILES) $(CC_BINUTILS_FILES_2)
 	@$(ECHO) '  IN    $(@)'
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/alphaev56-unknown-linux-gnu/crosstool.config
--- a/samples/alphaev56-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/alphaev56-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -10,7 +10,7 @@ 
 CT_BINUTILS_V_2_21_1a=y
 CT_BINUTILS_PLUGINS=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_5=y
+CT_CC_GCC_V_4_4_5=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/alphaev67-unknown-linux-gnu/crosstool.config
--- a/samples/alphaev67-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/alphaev67-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_38=y
 CT_BINUTILS_V_2_21_1a=y
-CT_CC_V_4_3_5=y
+CT_CC_GCC_V_4_3_5=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 # CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-bare_newlib_cortex_m3_nommu-eabi/crosstool.config
--- a/samples/arm-bare_newlib_cortex_m3_nommu-eabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-bare_newlib_cortex_m3_nommu-eabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -11,7 +11,7 @@ 
 CT_TARGET_VENDOR="bare_newlib_cortex_m3_nommu"
 CT_ARCH_BINFMT_FLAT=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_4_1=y
+CT_CC_GCC_V_4_4_1=y
 CT_CC_LANG_CXX=y
 CT_LIBC_NEWLIB_V_1_18_0=y
 CT_GMP_V_4_3_2=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-cortex_a8-linux-gnueabi/crosstool.config
--- a/samples/arm-cortex_a8-linux-gnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-cortex_a8-linux-gnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -10,7 +10,7 @@ 
 CT_KERNEL_linux=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_6=y
+CT_CC_GCC_V_4_4_6=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-cortexa9_neon-linux-gnueabihf/crosstool.config
--- a/samples/arm-cortexa9_neon-linux-gnueabihf/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-cortexa9_neon-linux-gnueabihf/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -18,7 +18,7 @@ 
 CT_BINUTILS_PLUGINS=y
 CT_BINUTILS_FOR_TARGET=y
 CT_CC_GCC_SHOW_LINARO=y
-CT_CC_V_linaro_4_7=y
+CT_CC_GCC_V_linaro_4_7=y
 CT_CC_LANG_CXX=y
 CT_CC_CORE_EXTRA_CONFIG_ARRAY="\"--with-specs=%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}\" --enable-poison-system-directories"
 CT_CC_EXTRA_CONFIG_ARRAY="\"--with-specs=%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}\" --enable-poison-system-directories"
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-davinci-linux-gnueabi/crosstool.config
--- a/samples/arm-davinci-linux-gnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-davinci-linux-gnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -11,7 +11,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-unknown-eabi/crosstool.config
--- a/samples/arm-unknown-eabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-unknown-eabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -4,7 +4,7 @@ 
 CT_ARCH_FLOAT_SW=y
 CT_ARCH_arm=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_4=y
+CT_CC_GCC_V_4_3_4=y
 CT_CC_LANG_CXX=y
 CT_LIBC_NEWLIB_V_1_17_0=y
 CT_DEBUG_gdb=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-unknown-linux-gnueabi/crosstool.config
--- a/samples/arm-unknown-linux-gnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-unknown-linux-gnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_linux=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/arm-unknown-linux-uclibcgnueabi/crosstool.config
--- a/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -11,7 +11,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_3=y
+CT_CC_GCC_V_4_4_3=y
 CT_CC_LANG_CXX=y
 CT_LIBC_uClibc=y
 CT_LIBC_UCLIBC_V_0_9_30_2=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/armeb-unknown-eabi/crosstool.config
--- a/samples/armeb-unknown-eabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/armeb-unknown-eabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -5,7 +5,7 @@ 
 CT_ARCH_FLOAT_SW=y
 CT_ARCH_arm=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_LIBC_none=y
 CT_DEBUG_gdb=y
 CT_GDB_V_6_8a=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/armeb-unknown-linux-gnueabi/crosstool.config
--- a/samples/armeb-unknown-linux-gnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/armeb-unknown-linux-gnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -11,7 +11,7 @@ 
 CT_KERNEL_linux=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_3=y
+CT_CC_GCC_V_4_4_3=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config
--- a/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -16,7 +16,7 @@ 
 CT_BINUTILS_LD_WRAPPER=y
 CT_BINUTILS_PLUGINS=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_6_4=y
+CT_CC_GCC_V_4_6_4=y
 CT_CC_LANG_CXX=y
 CT_CC_GCC_DISABLE_PCH=y
 # CT_CC_GCC_SJLJ_EXCEPTIONS is not set
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/avr32-unknown-none/crosstool.config
--- a/samples/avr32-unknown-none/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/avr32-unknown-none/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -4,7 +4,7 @@ 
 CT_LOG_EXTRA=y
 CT_ARCH_avr32=y
 CT_BINUTILS_V_2_18a=y
-CT_CC_V_4_2_2=y
+CT_CC_GCC_V_4_2_2=y
 CT_LIBC_NEWLIB_V_1_17_0=y
 CT_LIBC_NEWLIB_IO_LL=y
 CT_LIBC_NEWLIB_IO_FLOAT=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/bfin-unknown-linux-uclibc/crosstool.config
--- a/samples/bfin-unknown-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/bfin-unknown-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -6,7 +6,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_ARCH_BINFMT_FDPIC=y
 CT_BINUTILS_V_2_20_1a=y
-CT_CC_V_4_3_4=y
+CT_CC_GCC_V_4_3_4=y
 CT_LIBC_UCLIBC_V_0_9_30_2=y
 CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
 CT_GMP_V_4_3_2=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/i586-geode-linux-uclibc/crosstool.config
--- a/samples/i586-geode-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/i586-geode-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_V_2_6_36=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_5=y
+CT_CC_GCC_V_4_4_5=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/i586-mingw32msvc,i686-none-linux-gnu/crosstool.config
--- a/samples/i586-mingw32msvc,i686-none-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/i586-mingw32msvc,i686-none-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -12,7 +12,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_EXTRA_CONFIG_ARRAY="--enable-targets=i686-none-linux-gnu"
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/i686-nptl-linux-gnu/crosstool.config
--- a/samples/i686-nptl-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/i686-nptl-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -13,7 +13,7 @@ 
 CT_BINUTILS_LD_WRAPPER=y
 CT_BINUTILS_PLUGINS=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_5_2=y
+CT_CC_GCC_V_4_5_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/i686-unknown-mingw32/crosstool.config
--- a/samples/i686-unknown-mingw32/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/i686-unknown-mingw32/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_windows=y
 CT_BINUTILS_V_2_21_1a=y
 CT_BINUTILS_PLUGINS=y
-CT_CC_V_4_5_2=y
+CT_CC_GCC_V_4_5_2=y
 CT_CC_LANG_CXX=y
 CT_MINGW_DIRECTX=y
 CT_MINGW_DDK=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/m68k-unknown-elf/crosstool.config
--- a/samples/m68k-unknown-elf/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/m68k-unknown-elf/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -6,7 +6,7 @@ 
 CT_ARCH_m68k=y
 CT_ARCH_BINFMT_FLAT=y
 CT_BINUTILS_V_2_20_1a=y
-CT_CC_V_4_3_4=y
+CT_CC_GCC_V_4_3_4=y
 CT_LIBC_none=y
 CT_GMP_V_4_3_2=y
 CT_MPFR_V_2_4_2=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips-ar2315-linux-gnu/crosstool.config
--- a/samples/mips-ar2315-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips-ar2315-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -10,7 +10,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_EGLIBC_V_2_9=y
 CT_EGLIBC_REVISION="{2009-07-21}"
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips-malta-linux-gnu/crosstool.config
--- a/samples/mips-malta-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips-malta-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_38=y
 CT_BINUTILS_V_2_21_1a=y
-CT_CC_V_4_4_6=y
+CT_CC_GCC_V_4_4_6=y
 # CT_CC_GCC_USE_GRAPHITE is not set
 CT_LIBC_EGLIBC_V_2_13=y
 CT_DEBUG_gdb=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips-unknown-elf/crosstool.config
--- a/samples/mips-unknown-elf/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips-unknown-elf/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -4,7 +4,7 @@ 
 CT_ARCH_FLOAT_SW=y
 CT_ARCH_mips=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_LIBC_none=y
 CT_DEBUG_gdb=y
 CT_GDB_V_6_8a=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips-unknown-linux-uclibc/crosstool.config
--- a/samples/mips-unknown-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips-unknown-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_3_6=y
 CT_BINUTILS_V_2_21_1a=y
-CT_CC_V_4_6_4=y
+CT_CC_GCC_V_4_6_4=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_LIBC_uClibc=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips64el-n32-linux-uclibc/crosstool.config
--- a/samples/mips64el-n32-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips64el-n32-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -10,7 +10,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_uClibc=y
 CT_LIBC_UCLIBC_V_0_9_30_1=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mips64el-n64-linux-uclibc/crosstool.config
--- a/samples/mips64el-n64-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mips64el-n64-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -11,7 +11,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_uClibc=y
 CT_LIBC_UCLIBC_V_0_9_30_1=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mipsel-sde-elf/crosstool.config
--- a/samples/mipsel-sde-elf/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mipsel-sde-elf/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -6,7 +6,7 @@ 
 CT_ARCH_mips=y
 CT_TARGET_VENDOR="sde"
 CT_BINUTILS_V_2_21_1a=y
-CT_CC_V_4_4_6=y
+CT_CC_GCC_V_4_4_6=y
 # CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
 CT_LIBC_none=y
 CT_DEBUG_gdb=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/mipsel-unknown-linux-gnu/crosstool.config
--- a/samples/mipsel-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/mipsel-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -9,7 +9,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-405-linux-gnu/crosstool.config
--- a/samples/powerpc-405-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-405-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -10,7 +10,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-860-linux-gnu/crosstool.config
--- a/samples/powerpc-860-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-860-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -9,7 +9,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_EXTRA_CONFIG_ARRAY="--with-cpu=860 --enable-cxx-flags=-mcpu=860 --with-float=soft --enable-cxx-flags=-msoft-float"
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-e300c3-linux-gnu/crosstool.config
--- a/samples/powerpc-e300c3-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-e300c3-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -9,7 +9,7 @@ 
 CT_KERNEL_V_2_6_36=y
 CT_BINUTILS_V_2_21_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_5_2=y
+CT_CC_GCC_V_4_5_2=y
 CT_CC_LANG_CXX=y
 CT_CC_EXTRA_CONFIG_ARRAY="--with-long-double-128"
 # CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-e500v2-linux-gnuspe/crosstool.config
--- a/samples/powerpc-e500v2-linux-gnuspe/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-e500v2-linux-gnuspe/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -14,7 +14,7 @@ 
 CT_BINUTILS_EXTRA_CONFIG_ARRAY="--enable-spe=yes --enable-e500x2 --with-e500x2"
 CT_BINUTILS_FOR_TARGET=y
 CT_CC_GCC_SHOW_LINARO=y
-CT_CC_V_4_6_4=y
+CT_CC_GCC_V_4_6_4=y
 CT_CC_LANG_CXX=y
 CT_CC_EXTRA_CONFIG_ARRAY="--with-long-double-128"
 # CT_CC_GCC_ENABLE_TARGET_OPTSPACE is not set
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-unknown-linux-gnu/crosstool.config
--- a/samples/powerpc-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -6,7 +6,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-unknown-linux-uclibc/crosstool.config
--- a/samples/powerpc-unknown-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-unknown-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_2_4=y
+CT_CC_GCC_V_4_2_4=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_LIBC_uClibc=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config
--- a/samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/powerpc64-unknown-linux-gnu/crosstool.config
--- a/samples/powerpc64-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/powerpc64-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_5_2=y
+CT_CC_GCC_V_4_5_2=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/s390-ibm-linux-gnu/crosstool.config
--- a/samples/s390-ibm-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/s390-ibm-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -6,7 +6,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_20_1a=y
-CT_CC_V_4_3_4=y
+CT_CC_GCC_V_4_3_4=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/s390x-ibm-linux-gnu/crosstool.config
--- a/samples/s390x-ibm-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/s390x-ibm-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -8,7 +8,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_31=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_4_5=y
+CT_CC_GCC_V_4_4_5=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/sh4-unknown-linux-gnu/crosstool.config
--- a/samples/sh4-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/sh4-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_linux=y
 CT_KERNEL_V_2_6_27=y
 CT_BINUTILS_V_2_19_1a=y
-CT_CC_V_4_3_2=y
+CT_CC_GCC_V_4_3_2=y
 CT_CC_LANG_CXX=y
 CT_LIBC_glibc=y
 CT_LIBC_GLIBC_V_2_9=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/x86_64-unknown-linux-gnu/crosstool.config
--- a/samples/x86_64-unknown-linux-gnu/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/x86_64-unknown-linux-gnu/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_3=y
+CT_CC_GCC_V_4_4_3=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/x86_64-unknown-linux-uclibc/crosstool.config
--- a/samples/x86_64-unknown-linux-uclibc/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/x86_64-unknown-linux-uclibc/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_V_2_6_33=y
 CT_BINUTILS_V_2_20_1a=y
 CT_BINUTILS_FOR_TARGET=y
-CT_CC_V_4_4_3=y
+CT_CC_GCC_V_4_4_3=y
 CT_CC_LANG_FORTRAN=y
 CT_CC_LANG_CXX=y
 CT_CC_LANG_JAVA=y
diff -r 7e569a9cb5fd -r cc545a5c1896 samples/x86_64-unknown-mingw32/crosstool.config
--- a/samples/x86_64-unknown-mingw32/crosstool.config	Sat Nov 16 18:14:45 2013 +0100
+++ b/samples/x86_64-unknown-mingw32/crosstool.config	Wed Dec 11 21:28:37 2013 +0100
@@ -7,7 +7,7 @@ 
 CT_KERNEL_windows=y
 CT_BINUTILS_V_2_21_1a=y
 CT_BINUTILS_PLUGINS=y
-CT_CC_V_4_5_2=y
+CT_CC_GCC_V_4_5_2=y
 CT_CC_LANG_CXX=y
 CT_MINGW_DIRECTX=y
 CT_MINGW_DDK=y
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/cc.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/cc.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -0,0 +1,59 @@ 
+# Wrapper to build the companion tools facilities
+
+# List all companion tools facilities, and parse their scripts
+CT_CC_FACILITY_LIST=
+for f in "${CT_LIB_DIR}/scripts/build/cc/"*.sh; do
+    _f="$(basename "${f}" .sh)"
+    _f="${_f#???-}"
+    __f="CT_CC_${_f}"
+    if [ "${!__f}" = "y" ]; then
+        CT_DoLog DEBUG "Enabling cc '${_f}'"
+        . "${f}"
+        CT_CC_FACILITY_LIST="${CT_CC_FACILITY_LIST} ${_f}"
+    else
+        CT_DoLog DEBUG "Disabling cc '${_f}'"
+    fi
+done
+
+# Download the cc facilities
+do_cc_get() {
+    for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_get
+    done
+}
+
+# Extract and patch the cc facilities
+do_cc_extract() {
+    for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_extract
+    done
+}
+
+# Core pass 1 the cc facilities
+do_cc_core_pass_1() {
+    for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_core_pass_1
+    done
+}
+
+# Core pass 2 the cc facilities
+do_cc_core_pass_2() {
+	for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_core_pass_2
+    done
+}
+
+# Build for build the cc facilities
+do_cc_for_build() {
+	for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_for_build
+    done
+}
+
+# Build for host the cc facilities
+do_cc_for_host() {
+	for f in ${CT_CC_FACILITY_LIST}; do
+        do_${f}_for_host
+    done
+}
+
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/cc/100-gcc.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/cc/100-gcc.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -0,0 +1,874 @@ 
+# This file adds the function to build the gcc C compiler
+# Copyright 2007 Yann E. MORIN
+# Licensed under the GPL v2. See COPYING in the root of this package
+
+# Download gcc
+do_gcc_get() {
+    local linaro_version
+    local linaro_series
+    local linaro_base_url="http://launchpad.net/gcc-linaro"
+
+    if [ "${CT_CC_GCC_CUSTOM}" = "y" ]; then
+        CT_GetCustom "gcc" "${CT_CC_GCC_VERSION}" "${CT_CC_GCC_CUSTOM_LOCATION}"
+    else
+        # Account for the Linaro versioning
+        linaro_version="$( echo "${CT_CC_GCC_VERSION}"  \
+                           |sed -r -e 's/^linaro-//;'   \
+                         )"
+        linaro_series="$( echo "${linaro_version}"      \
+                          |sed -r -e 's/-.*//;'         \
+                        )"
+
+        # Ah! gcc folks are kind of 'different': they store the tarballs in
+        # subdirectories of the same name!
+        # Arrgghh! Some of those versions does not follow this convention:
+        # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
+        # subdirectory!
+        CT_GetFile "gcc-${CT_CC_GCC_VERSION}"                                                       \
+                   {ftp,http}://ftp.gnu.org/gnu/gcc{,{,/releases}/gcc-${CT_CC_GCC_VERSION}}         \
+                   ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-${CT_CC_GCC_VERSION} \
+                   ftp://ftp.uvsq.fr/pub/gcc/snapshots/${CT_CC_GCC_VERSION}                         \
+                   "${linaro_base_url}/${linaro_series}/${linaro_version}/+download"
+    fi # ! custom location
+    # Starting with GCC 4.3, ecj is used for Java, and will only be
+    # built if the configure script finds ecj.jar at the top of the
+    # GCC source tree, which will not be there unless we get it and
+    # put it there ourselves
+    if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
+        CT_GetFile ecj-latest .jar ftp://gcc.gnu.org/pub/java   \
+                                   ftp://sourceware.org/pub/java
+    fi
+}
+
+# Extract gcc
+do_gcc_extract() {
+    # If using custom directory location, nothing to do
+    if [ "${CT_CC_GCC_CUSTOM}" = "y"                    \
+         -a -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}" ]; then
+        return 0
+    fi
+
+    CT_Extract "gcc-${CT_CC_GCC_VERSION}"
+    CT_Patch "gcc" "${CT_CC_GCC_VERSION}"
+
+    # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree
+    if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y"                     \
+         -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar"   \
+       ]; then
+        CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/ecj.jar"
+    fi
+}
+
+#------------------------------------------------------------------------------
+# This function builds up the set of languages to enable
+# No argument expected, returns the comma-separated language list on stdout
+cc_gcc_lang_list() {
+    local lang_list
+
+    lang_list="c"
+    [ "${CT_CC_LANG_CXX}" = "y"      ] && lang_list+=",c++"
+    [ "${CT_CC_LANG_FORTRAN}" = "y"  ] && lang_list+=",fortran"
+    [ "${CT_CC_LANG_ADA}" = "y"      ] && lang_list+=",ada"
+    [ "${CT_CC_LANG_JAVA}" = "y"     ] && lang_list+=",java"
+    [ "${CT_CC_LANG_OBJC}" = "y"     ] && lang_list+=",objc"
+    [ "${CT_CC_LANG_OBJCXX}" = "y"   ] && lang_list+=",obj-c++"
+    [ "${CT_CC_LANG_GOLANG}" = "y"   ] && lang_list+=",go"
+    lang_list+="${CT_CC_LANG_OTHERS:+,${CT_CC_LANG_OTHERS}}"
+
+    printf "%s" "${lang_list}"
+}
+
+#------------------------------------------------------------------------------
+# Core gcc pass 1
+do_gcc_core_pass_1() {
+    local -a core_opts
+
+    if [ "${CT_CC_CORE_PASSES_NEEDED}" != "y" ]; then
+        return 0
+    fi
+
+    core_opts+=( "mode=static" )
+    core_opts+=( "host=${CT_BUILD}" )
+    core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+    core_opts+=( "lang_list=c" )
+
+    CT_DoStep INFO "Installing pass-1 core C gcc compiler"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1"
+
+    do_gcc_core_backend "${core_opts[@]}"
+
+    CT_Popd
+    CT_EndStep
+}
+
+# Core gcc pass 2
+do_gcc_core_pass_2() {
+    local -a core_opts
+
+    if [ "${CT_CC_CORE_PASSES_NEEDED}" != "y" ]; then
+        return 0
+    fi
+
+    # Common options:
+    core_opts+=( "host=${CT_BUILD}" )
+    core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+    core_opts+=( "lang_list=c" )
+
+    # Different conditions are at stake here:
+    #   - In case the threading model is NPTL, we need a shared-capable core
+    #     gcc; in all other cases, we need a static-only core gcc.
+    #   - In case the threading model is NPTL or win32, or gcc is 4.3 or
+    #     later, we need to build libgcc
+    case "${CT_THREADS}" in
+        nptl)
+            core_opts+=( "mode=shared" )
+            core_opts+=( "build_libgcc=yes" )
+            ;;
+        win32)
+            core_opts+=( "mode=static" )
+            core_opts+=( "build_libgcc=yes" )
+            ;;
+        *)
+            core_opts+=( "mode=static" )
+            if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
+                core_opts+=( "build_libgcc=yes" )
+            fi
+            ;;
+    esac
+
+    CT_DoStep INFO "Installing pass-2 core C gcc compiler"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2"
+
+    do_gcc_core_backend "${core_opts[@]}"
+
+    CT_Popd
+    CT_EndStep
+}
+
+#------------------------------------------------------------------------------
+# Build core gcc
+# This function is used to build the core C compiler.
+# Usage: do_gcc_core_backend param=value [...]
+#   Parameter           : Definition                                : Type      : Default
+#   mode                : build a 'static', 'shared' or 'baremetal' : string    : (none)
+#   host                : the machine the core will run on          : tuple     : (none)
+#   prefix              : dir prefix to install into                : dir       : (none)
+#   complibs            : dir where complibs are isntalled          : dir       : (none)
+#   lang_list           : the list of languages to build            : string    : (empty)
+#   build_libgcc        : build libgcc or not                       : bool      : no
+#   build_libstdcxx     : build libstdc++ or not                    : bool      : no
+#   build_staticlinked  : build statically linked or not            : bool      : no
+#   build_manuals       : whether to build manuals or not           : bool      : no
+#   cflags              : cflags to use                             : string    : (empty)
+#   ldflags             : ldflags to use                            : string    : (empty)
+# Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
+do_gcc_core_backend() {
+    local mode
+    local build_libgcc=no
+    local build_libstdcxx=no
+    local build_staticlinked=no
+    local build_manuals=no
+    local host
+    local prefix
+    local complibs
+    local lang_list
+    local cflags
+    local ldflags
+    local tmp
+    local -a host_libstdcxx_flags
+    local -a extra_config
+    local -a core_LDFLAGS
+    local -a core_targets
+    local arg
+    local exeext
+
+    for arg in "$@"; do
+        eval "${arg// /\\ }"
+    done
+
+    CT_DoLog EXTRA "Configuring core C gcc compiler"
+
+    case "${mode}" in
+        static)
+            extra_config+=("--with-newlib")
+            extra_config+=("--enable-threads=no")
+            extra_config+=("--disable-shared")
+            copy_headers=y  # For baremetal, as there's no headers to copy,
+                            # we copy an empty directory. So, who cares?
+            ;;
+        shared)
+            extra_config+=("--enable-shared")
+            copy_headers=y
+            ;;
+        baremetal)
+            extra_config+=("--with-newlib")
+            extra_config+=("--enable-threads=no")
+            extra_config+=("--disable-shared")
+            copy_headers=n
+            ;;
+        *)
+            CT_Abort "Internal Error: 'mode' must be one of: 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'"
+            ;;
+    esac
+
+    if [ "${CT_CC_GCC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
+        # Bare metal delivers the core compiler as final compiler, so add version info and bugurl
+        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+    fi
+
+    if [ "${copy_headers}" = "y" ]; then
+        CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
+        CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include"
+    fi
+
+    for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
+        eval tmp="\${CT_ARCH_WITH_${tmp}}"
+        if [ -n "${tmp}" ]; then
+            extra_config+=("${tmp}")
+        fi
+    done
+    if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
+        extra_config+=("--enable-__cxa_atexit")
+    else
+        extra_config+=("--disable-__cxa_atexit")
+    fi
+
+    core_LDFLAGS+=("${ldflags}")
+
+    # *** WARNING ! ***
+    # Keep this full if-else-if-elif-fi-fi block in sync
+    # with the same block in do_gcc, below.
+    if [ "${build_staticlinked}" = "yes" ]; then
+        core_LDFLAGS+=("-static")
+        host_libstdcxx_flags+=("-static-libgcc")
+        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
+        host_libstdcxx_flags+=("-lm")
+        # Companion libraries are build static (eg !shared), so
+        # the libstdc++ is not pulled automatically, although it
+        # is needed. Shoe-horn it in our LDFLAGS
+        # Ditto libm on some Fedora boxen
+        core_LDFLAGS+=("-lstdc++")
+        core_LDFLAGS+=("-lm")
+    else
+        if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
+            # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
+            # build script
+            # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
+            #       see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
+            host_libstdcxx_flags+=("-static-libgcc")
+            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
+            host_libstdcxx_flags+=("-lm")
+        elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
+            # When companion libraries are build static (eg !shared),
+            # the libstdc++ is not pulled automatically, although it
+            # is needed. Shoe-horn it in our LDFLAGS
+            # Ditto libm on some Fedora boxen
+            core_LDFLAGS+=("-lstdc++")
+            core_LDFLAGS+=("-lm")
+        fi
+    fi
+
+    if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
+        extra_config+=("--with-gmp=${complibs}")
+        extra_config+=("--with-mpfr=${complibs}")
+    fi
+    if [ "${CT_CC_GCC_USE_MPC}" = "y" ]; then
+        extra_config+=("--with-mpc=${complibs}")
+    fi
+    if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
+        if [ "${CT_PPL}" = "y" ]; then
+            extra_config+=("--with-ppl=${complibs}")
+            # With PPL 0.11+, also pull libpwl if needed
+            if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
+                host_libstdcxx_flags+=("-L${complibs}/lib")
+                host_libstdcxx_flags+=("-lpwl")
+            fi
+        fi
+        if [ "${CT_ISL}" = "y" ]; then
+            extra_config+=("--with-isl=${complibs}")
+        fi
+        extra_config+=("--with-cloog=${complibs}")
+    elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
+        extra_config+=("--with-ppl=no")
+        extra_config+=("--with-isl=no")
+        extra_config+=("--with-cloog=no")
+    fi
+    if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then
+        extra_config+=("--with-libelf=${complibs}")
+        extra_config+=("--enable-lto")
+    elif [ "${CT_CC_GCC_HAS_LTO}" = "y" ]; then
+        extra_config+=("--with-libelf=no")
+        extra_config+=("--disable-lto")
+    fi
+
+    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
+        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
+    fi
+
+    if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+        extra_config+=("--enable-target-optspace")
+    fi
+
+    case "${CT_CC_GCC_LDBL_128}" in
+        y)  extra_config+=("--with-long-double-128");;
+        m)  ;;
+        "") extra_config+=("--without-long-double-128");;
+    esac
+
+    if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then
+        extra_config+=( --enable-linker-build-id )
+    fi
+
+    case "${CT_CC_GCC_LNK_HASH_STYLE}" in
+        "") ;;
+        *)  extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );;
+    esac
+
+    case "${CT_ARCH}" in
+        mips)
+            case "${CT_CC_GCC_mips_llsc}" in
+                y)  extra_config+=( --with-llsc );;
+                m)  ;;
+                *)  extra_config+=( --without-llsc );;
+            esac
+            case "${CT_CC_GCC_mips_synci}" in
+                y)  extra_config+=( --with-synci );;
+                m)  ;;
+                *)  extra_config+=( --without-synci );;
+            esac
+            if [ "${CT_CC_GCC_mips_plt}" ]; then
+                extra_config+=( --with-mips-plt )
+            fi
+            ;; # ARCH is mips
+    esac
+
+    extra_config+=(--disable-libgomp)
+    extra_config+=(--disable-libmudflap)
+
+    [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
+
+    [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ] && extra_config+=("--disable-libstdcxx-pch")
+
+    if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
+        extra_config+=("--with-system-zlib")
+    fi
+
+    if [ "${CT_MULTILIB}" = "y" ]; then
+        extra_config+=("--enable-multilib")
+    else
+        extra_config+=("--disable-multilib")
+    fi
+
+    CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
+
+    # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
+    CT_DoExecLog CFG                                \
+    CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
+    CFLAGS_FOR_BUILD="${CT_EXTRA_CFLAGS_FOR_BUILD-${cflags}}" \
+    CFLAGS="${cflags}"                              \
+    CXXFLAGS="${cflags}"                            \
+    LDFLAGS="${core_LDFLAGS[*]}"                    \
+    "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure"  \
+        --build=${CT_BUILD}                         \
+        --host=${host}                              \
+        --target=${CT_TARGET}                       \
+        --prefix="${prefix}"                        \
+        --with-local-prefix="${CT_SYSROOT_DIR}"     \
+        --disable-libmudflap                        \
+        ${CC_CORE_SYSROOT_ARG}                      \
+        "${extra_config[@]}"                        \
+        --enable-languages="${lang_list}"           \
+        "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}"
+
+    if [ "${build_libgcc}" = "yes" ]; then
+        # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
+        # gcc/config/t-libunwind so -lc is removed from the link for
+        # libgcc_s.so, as we do not have a target -lc yet.
+        # This is not as ugly as it appears to be ;-) All symbols get resolved
+        # during the glibc build, and we provide a proper libgcc_s.so for the
+        # cross toolchain during the final gcc build.
+        #
+        # As we cannot modify the source tree, nor override SHLIB_LC itself
+        # during configure or make, we have to edit the resultant
+        # gcc/libgcc.mk itself to remove -lc from the link.
+        # This causes us to have to jump through some hoops...
+        #
+        # To produce libgcc.mk to edit we firstly require libiberty.a,
+        # so we configure then build it.
+        # Next we have to configure gcc, create libgcc.mk then edit it...
+        # So much easier if we just edit the source tree, but hey...
+        if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
+            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty
+            CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a
+            CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp
+            CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp
+        else
+            CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty
+            CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty
+        fi
+        # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
+        if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libdecnumber" ]; then
+            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber
+            CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a
+        fi
+        # HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here.
+        if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/libbacktrace" ]; then
+            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace
+            CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace
+        fi
+
+        # Starting with GCC 4.3, libgcc.mk is no longer built,
+        # and libgcc.mvars is used instead.
+
+        if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
+            libgcc_rule="libgcc.mvars"
+            core_targets=( gcc target-libgcc )
+        else
+            libgcc_rule="libgcc.mk"
+            core_targets=( gcc )
+        fi
+
+        # On bare metal and canadian build the host-compiler is used when
+        # actually the build-system compiler is required. Choose the correct
+        # compilers for canadian build and use the defaults on other
+        # configurations.
+        if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then
+            repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \
+                       CXX_FOR_BUILD=${CT_BUILD}-g++ \
+                       GCC_FOR_TARGET=${CT_TARGET}-gcc"
+        else
+            repair_cc=""
+        fi
+
+        CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \
+                              ${repair_cc}
+        sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
+    else # build_libgcc
+        core_targets=( gcc )
+    fi   # ! build libgcc
+    if [    "${build_libstdcxx}" = "yes"    \
+         -a "${CT_CC_LANG_CXX}"  = "y"      \
+       ]; then
+        core_targets+=( target-libstdc++-v3 )
+    fi
+
+    CT_DoLog EXTRA "Building core C gcc compiler"
+    CT_DoExecLog ALL make ${JOBSFLAGS} "${core_targets[@]/#/all-}"
+
+    CT_DoLog EXTRA "Installing core C gcc compiler"
+    CT_DoExecLog ALL make ${JOBSFLAGS} "${core_targets[@]/#/install-}"
+
+    if [ "${build_manuals}" = "yes" ]; then
+        CT_DoLog EXTRA "Building the gcc manuals"
+        CT_DoExecLog ALL make pdf html
+        CT_DoLog EXTRA "Installing the gcc manuals"
+        CT_DoExecLog ALL make install-{pdf,html}-gcc
+    fi
+
+    # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
+    # to call the C compiler with the same, somewhat canonical name.
+    # check whether compiler has an extension
+    file="$( ls -1 "${prefix}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )"
+    [ -z "${file}" ] || ext=".${file##*.}"
+    CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}"
+
+    if [ "${CT_MULTILIB}" = "y" ]; then
+        if [ "${CT_CANADIAN}" = "y" -a "${mode}" = "baremetal" \
+             -a "${host}" = "${CT_HOST}" ]; then
+            CT_DoLog WARN "Canadian Cross unable to confirm multilibs configured correctly"
+        else
+            multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib   \
+                           |tail -n +2 ) )
+            if [ ${#multilibs[@]} -ne 0 ]; then
+                CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):"
+                for i in "${multilibs[@]}"; do
+                    dir="${i%%;*}"
+                    flags="${i#*;}"
+                    CT_DoLog EXTRA "   ${flags//@/ -}  -->  ${dir}/"
+                done
+            else
+                CT_DoLog WARN "gcc configured for multilib, but none available"
+           fi
+        fi
+    fi
+}
+
+#------------------------------------------------------------------------------
+# Build complete gcc to run on build
+do_gcc_for_build() {
+    local -a build_final_opts
+    local build_final_backend
+
+    # In case we're canadian or cross-native, it seems that a
+    # real, complete compiler is needed?!? WTF? Sigh...
+    # Otherwise, there is nothing to do.
+    case "${CT_TOOLCHAIN_TYPE}" in
+        native|cross)   return 0;;
+    esac
+
+    build_final_opts+=( "host=${CT_BUILD}" )
+    build_final_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    build_final_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
+    build_final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
+    if [ "${CT_BARE_METAL}" = "y" ]; then
+        # In the tests I've done, bare-metal was not impacted by the
+        # lack of such a compiler, but better safe than sorry...
+        build_final_opts+=( "mode=baremetal" )
+        build_final_opts+=( "build_libgcc=yes" )
+        build_final_opts+=( "build_libstdcxx=yes" )
+        if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+            build_final_opts+=( "build_staticlinked=yes" )
+        fi
+        build_final_backend=do_gcc_core_backend
+    else
+        build_final_backend=do_gcc_backend
+    fi
+
+    CT_DoStep INFO "Installing final gcc compiler for build"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final-build-${CT_BUILD}"
+
+    "${build_final_backend}" "${build_final_opts[@]}"
+
+    CT_Popd
+    CT_EndStep
+}
+
+#------------------------------------------------------------------------------
+# Build final gcc to run on host
+do_gcc_for_host() {
+    local -a final_opts
+    local final_backend
+
+    final_opts+=( "host=${CT_HOST}" )
+    final_opts+=( "prefix=${CT_PREFIX_DIR}" )
+    final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
+    final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+    final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
+    final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
+    if [ "${CT_BUILD_MANUALS}" = "y" ]; then
+        final_opts+=( "build_manuals=yes" )
+    fi
+    if [ "${CT_BARE_METAL}" = "y" ]; then
+        final_opts+=( "mode=baremetal" )
+        final_opts+=( "build_libgcc=yes" )
+        final_opts+=( "build_libstdcxx=yes" )
+        if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+            final_opts+=( "build_staticlinked=yes" )
+        fi
+        final_backend=do_gcc_core_backend
+    else
+        final_backend=do_gcc_backend
+    fi
+
+    CT_DoStep INFO "Installing final gcc compiler"
+    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-final"
+
+    "${final_backend}" "${final_opts[@]}"
+
+    CT_Popd
+    CT_EndStep
+}
+
+#------------------------------------------------------------------------------
+# Build the final gcc
+# Usage: do_gcc_backend param=value [...]
+#   Parameter     : Definition                          : Type      : Default
+#   host          : the host we run onto                : tuple     : (none)
+#   prefix        : the runtime prefix                  : dir       : (none)
+#   complibs      : the companion libraries prefix      : dir       : (none)
+#   cflags        : cflags to use                       : string    : (empty)
+#   ldflags       : ldflags to use                      : string    : (empty)
+#   lang_list     : the list of languages to build      : string    : (empty)
+#   build_manuals : whether to build manuals or not     : bool      : no
+do_gcc_backend() {
+    local host
+    local prefix
+    local complibs
+    local cflags
+    local ldflags
+    local lang_list
+    local build_manuals
+    local -a host_libstdcxx_flags
+    local -a extra_config
+    local -a final_LDFLAGS
+    local tmp
+    local arg
+    local exeext
+
+    for arg in "$@"; do
+        eval "${arg// /\\ }"
+    done
+
+    CT_DoLog EXTRA "Configuring final gcc compiler"
+
+    # Enable selected languages
+    extra_config+=("--enable-languages=${lang_list}")
+
+    for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
+        eval tmp="\${CT_ARCH_WITH_${tmp}}"
+        if [ -n "${tmp}" ]; then
+            extra_config+=("${tmp}")
+        fi
+    done
+
+    [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared")
+    if [ "${CT_CC_GCC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
+        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
+        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
+    fi
+    case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in
+        y)  extra_config+=("--enable-sjlj-exceptions");;
+        m)  ;;
+        "") extra_config+=("--disable-sjlj-exceptions");;
+    esac
+    if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
+        extra_config+=("--enable-__cxa_atexit")
+    else
+        extra_config+=("--disable-__cxa_atexit")
+    fi
+    if [ -n "${CT_CC_GCC_ENABLE_CXX_FLAGS}" ]; then
+        extra_config+=("--enable-cxx-flags=${CT_CC_GCC_ENABLE_CXX_FLAGS}")
+    fi
+    if [ "${CT_CC_GCC_LIBMUDFLAP}" = "y" ]; then
+        extra_config+=(--enable-libmudflap)
+    else
+        extra_config+=(--disable-libmudflap)
+    fi
+    if [ "${CT_CC_GCC_LIBGOMP}" = "y" ]; then
+        extra_config+=(--enable-libgomp)
+    else
+        extra_config+=(--disable-libgomp)
+    fi
+    if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
+        extra_config+=(--enable-libssp)
+    else
+        extra_config+=(--disable-libssp)
+    fi
+    if [ "${CT_CC_GCC_HAS_LIBQUADMATH}" = "y" ]; then
+        if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then
+            extra_config+=(--enable-libquadmath)
+            extra_config+=(--enable-libquadmath-support)
+        else
+            extra_config+=(--disable-libquadmath)
+            extra_config+=(--disable-libquadmath-support)
+        fi
+    fi
+
+    final_LDFLAGS+=("${ldflags}")
+
+    # *** WARNING ! ***
+    # Keep this full if-else-if-elif-fi-fi block in sync
+    # with the same block in do_gcc_core, above.
+    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
+        final_LDFLAGS+=("-static")
+        host_libstdcxx_flags+=("-static-libgcc")
+        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
+        host_libstdcxx_flags+=("-lm")
+        # Companion libraries are build static (eg !shared), so
+        # the libstdc++ is not pulled automatically, although it
+        # is needed. Shoe-horn it in our LDFLAGS
+        # Ditto libm on some Fedora boxen
+        final_LDFLAGS+=("-lstdc++")
+        final_LDFLAGS+=("-lm")
+    else
+        if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
+            # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
+            # build script
+            # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
+            #       see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
+            host_libstdcxx_flags+=("-static-libgcc")
+            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
+            host_libstdcxx_flags+=("-lm")
+        elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
+            # When companion libraries are build static (eg !shared),
+            # the libstdc++ is not pulled automatically, although it
+            # is needed. Shoe-horn it in our LDFLAGS
+            # Ditto libm on some Fedora boxen
+            final_LDFLAGS+=("-lstdc++")
+            final_LDFLAGS+=("-lm")
+        fi
+    fi
+
+    if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
+        extra_config+=("--with-gmp=${complibs}")
+        extra_config+=("--with-mpfr=${complibs}")
+    fi
+    if [ "${CT_CC_GCC_USE_MPC}" = "y" ]; then
+        extra_config+=("--with-mpc=${complibs}")
+    fi
+    if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
+        if [ "${CT_PPL}" = "y" ]; then
+            extra_config+=("--with-ppl=${complibs}")
+            # With PPL 0.11+, also pull libpwl if needed
+            if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
+                host_libstdcxx_flags+=("-L${complibs}/lib")
+                host_libstdcxx_flags+=("-lpwl")
+            fi
+        fi
+        if [ "${CT_ISL}" = "y" ]; then
+            extra_config+=("--with-isl=${complibs}")
+        fi
+        extra_config+=("--with-cloog=${complibs}")
+    elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
+        extra_config+=("--with-ppl=no")
+        extra_config+=("--with-isl=no")
+        extra_config+=("--with-cloog=no")
+    fi
+    if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then
+        extra_config+=("--with-libelf=${complibs}")
+    elif [ "${CT_CC_GCC_HAS_LTO}" = "y" ]; then
+        extra_config+=("--with-libelf=no")
+    fi
+
+    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
+        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
+    fi
+
+    if [ "${CT_THREADS}" = "none" ]; then
+        extra_config+=("--disable-threads")
+        if [ "${CT_CC_GCC_4_2_or_later}" = y ]; then
+            CT_Test "Disabling libgomp for no-thread gcc>=4.2" "${CT_CC_GCC_LIBGOMP}" = "Y"
+            extra_config+=("--disable-libgomp")
+        fi
+    else
+        if [ "${CT_THREADS}" = "win32" ]; then
+            extra_config+=("--enable-threads=win32")
+            extra_config+=("--disable-win32-registry")
+        else
+            extra_config+=("--enable-threads=posix")
+        fi
+    fi
+
+    if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
+        extra_config+=("--enable-target-optspace")
+    fi
+    if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then
+        extra_config+=("--disable-libstdcxx-pch")
+    fi
+
+    case "${CT_CC_GCC_LDBL_128}" in
+        y)  extra_config+=("--with-long-double-128");;
+        m)  ;;
+        "") extra_config+=("--without-long-double-128");;
+    esac
+
+    if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then
+        extra_config+=( --enable-linker-build-id )
+    fi
+
+    case "${CT_CC_GCC_LNK_HASH_STYLE}" in
+        "") ;;
+        *)  extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );;
+    esac
+
+    if [ "${CT_CC_GCC_ENABLE_PLUGINS}" = "y" ]; then
+        extra_config+=( --enable-plugin )
+    fi
+    if [ "${CT_CC_GCC_GOLD}" = "y" ]; then
+        extra_config+=( --enable-gold )
+    fi
+
+    case "${CT_ARCH}" in
+        mips)
+            case "${CT_CC_GCC_mips_llsc}" in
+                y)  extra_config+=( --with-llsc );;
+                m)  ;;
+                *)  extra_config+=( --without-llsc );;
+            esac
+            case "${CT_CC_GCC_mips_synci}" in
+                y)  extra_config+=( --with-synci );;
+                m)  ;;
+                *)  extra_config+=( --without-synci );;
+            esac
+            if [ "${CT_CC_GCC_mips_plt}" ]; then
+                extra_config+=( --with-mips-plt )
+            fi
+            ;; # ARCH is mips
+    esac
+
+    [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
+
+    if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
+        extra_config+=("--with-system-zlib")
+    fi
+
+    if [ "${CT_MULTILIB}" = "y" ]; then
+        extra_config+=("--enable-multilib")
+    else
+        extra_config+=("--disable-multilib")
+    fi
+
+    CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
+
+    CT_DoExecLog CFG                                \
+    CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
+    CFLAGS_FOR_BUILD="${CT_EXTRA_CFLAGS_FOR_BUILD-${cflags}}" \
+    CFLAGS="${cflags}"                              \
+    CXXFLAGS="${cflags}"                            \
+    LDFLAGS="${final_LDFLAGS[*]}"                   \
+    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"         \
+    CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"       \
+    LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}"       \
+    "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/configure"  \
+        --build=${CT_BUILD}                         \
+        --host=${host}                              \
+        --target=${CT_TARGET}                       \
+        --prefix="${prefix}"                        \
+        ${CC_SYSROOT_ARG}                           \
+        "${extra_config[@]}"                        \
+        --with-local-prefix="${CT_SYSROOT_DIR}"     \
+        --enable-c99                                \
+        --enable-long-long                          \
+        "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}"
+
+    if [ "${CT_CANADIAN}" = "y" ]; then
+        CT_DoLog EXTRA "Building libiberty"
+        CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty
+    fi
+
+    CT_DoLog EXTRA "Building final gcc compiler"
+    CT_DoExecLog ALL make ${JOBSFLAGS} all
+
+    CT_DoLog EXTRA "Installing final gcc compiler"
+    CT_DoExecLog ALL make ${JOBSFLAGS} install
+
+    if [ "${build_manuals}" = "yes" ]; then
+        CT_DoLog EXTRA "Building the gcc manuals"
+        CT_DoExecLog ALL make pdf html
+        CT_DoLog EXTRA "Installing the gcc manuals"
+        CT_DoExecLog ALL make install-{pdf,html}-gcc
+    fi
+
+    # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
+    # to call the C compiler with the same, somewhat canonical name.
+    # check whether compiler has an extension
+    file="$( ls -1 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )"
+    [ -z "${file}" ] || ext=".${file##*.}"
+    CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-cc${ext}"
+
+    if [ "${CT_MULTILIB}" = "y" ]; then
+        if [ "${CT_CANADIAN}" = "y" ]; then
+            CT_DoLog WARN "Canadian Cross unable to confirm multilibs configured correctly"
+        else
+            multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib \
+                           |tail -n +2 ) )
+            if [ ${#multilibs[@]} -ne 0 ]; then
+                CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):"
+                for i in "${multilibs[@]}"; do
+                    dir="${i%%;*}"
+                    flags="${i#*;}"
+                    CT_DoLog EXTRA "   ${flags//@/ -}  -->  ${dir}/"
+                done
+            else
+                CT_DoLog WARN "gcc configured for multilib, but none available"
+            fi
+        fi
+    fi
+}
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/cc/gcc.sh
--- a/scripts/build/cc/gcc.sh	Sat Nov 16 18:14:45 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,869 +0,0 @@ 
-# This file adds the function to build the gcc C compiler
-# Copyright 2007 Yann E. MORIN
-# Licensed under the GPL v2. See COPYING in the root of this package
-
-# Download gcc
-do_cc_get() {
-    local linaro_version
-    local linaro_series
-    local linaro_base_url="http://launchpad.net/gcc-linaro"
-
-    if [ "${CT_CC_CUSTOM}" = "y" ]; then
-        CT_GetCustom "gcc" "${CT_CC_VERSION}" "${CT_CC_CUSTOM_LOCATION}"
-    else
-        # Account for the Linaro versioning
-        linaro_version="$( echo "${CT_CC_VERSION}"      \
-                           |sed -r -e 's/^linaro-//;'   \
-                         )"
-        linaro_series="$( echo "${linaro_version}"      \
-                          |sed -r -e 's/-.*//;'         \
-                        )"
-
-        # Ah! gcc folks are kind of 'different': they store the tarballs in
-        # subdirectories of the same name!
-        # Arrgghh! Some of those versions does not follow this convention:
-        # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
-        # subdirectory!
-        CT_GetFile "gcc-${CT_CC_VERSION}"                                                       \
-                   {ftp,http}://ftp.gnu.org/gnu/gcc{,{,/releases}/gcc-${CT_CC_VERSION}}         \
-                   ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/releases/gcc-${CT_CC_VERSION} \
-                   ftp://ftp.uvsq.fr/pub/gcc/snapshots/${CT_CC_VERSION}                         \
-                   "${linaro_base_url}/${linaro_series}/${linaro_version}/+download"
-
-    fi # ! custom location
-    # Starting with GCC 4.3, ecj is used for Java, and will only be
-    # built if the configure script finds ecj.jar at the top of the
-    # GCC source tree, which will not be there unless we get it and
-    # put it there ourselves
-    if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y" ]; then
-        CT_GetFile ecj-latest .jar ftp://gcc.gnu.org/pub/java   \
-                                   ftp://sourceware.org/pub/java
-    fi
-}
-
-# Extract gcc
-do_cc_extract() {
-    # If using custom directory location, nothing to do
-    if [ "${CT_CC_CUSTOM}" = "y"                    \
-         -a -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}" ]; then
-        return 0
-    fi
-
-    CT_Extract "gcc-${CT_CC_VERSION}"
-    CT_Patch "gcc" "${CT_CC_VERSION}"
-
-    # Copy ecj-latest.jar to ecj.jar at the top of the GCC source tree
-    if [ "${CT_CC_LANG_JAVA_USE_ECJ}" = "y"                     \
-         -a ! -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"   \
-       ]; then
-        CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"
-    fi
-}
-
-#------------------------------------------------------------------------------
-# This function builds up the set of languages to enable
-# No argument expected, returns the comma-separated language list on stdout
-cc_gcc_lang_list() {
-    local lang_list
-
-    lang_list="c"
-    [ "${CT_CC_LANG_CXX}" = "y"      ] && lang_list+=",c++"
-    [ "${CT_CC_LANG_FORTRAN}" = "y"  ] && lang_list+=",fortran"
-    [ "${CT_CC_LANG_ADA}" = "y"      ] && lang_list+=",ada"
-    [ "${CT_CC_LANG_JAVA}" = "y"     ] && lang_list+=",java"
-    [ "${CT_CC_LANG_OBJC}" = "y"     ] && lang_list+=",objc"
-    [ "${CT_CC_LANG_OBJCXX}" = "y"   ] && lang_list+=",obj-c++"
-    [ "${CT_CC_LANG_GOLANG}" = "y"   ] && lang_list+=",go"
-    lang_list+="${CT_CC_LANG_OTHERS:+,${CT_CC_LANG_OTHERS}}"
-
-    printf "%s" "${lang_list}"
-}
-
-#------------------------------------------------------------------------------
-# Core gcc pass 1
-do_cc_core_pass_1() {
-    local -a core_opts
-
-    if [ "${CT_CC_CORE_PASSES_NEEDED}" != "y" ]; then
-        return 0
-    fi
-
-    core_opts+=( "mode=static" )
-    core_opts+=( "host=${CT_BUILD}" )
-    core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
-    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
-    core_opts+=( "lang_list=c" )
-
-    CT_DoStep INFO "Installing pass-1 core C compiler"
-    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-core-pass-1"
-
-    do_cc_core_backend "${core_opts[@]}"
-
-    CT_Popd
-    CT_EndStep
-}
-
-# Core gcc pass 2
-do_cc_core_pass_2() {
-    local -a core_opts
-
-    if [ "${CT_CC_CORE_PASSES_NEEDED}" != "y" ]; then
-        return 0
-    fi
-
-    # Common options:
-    core_opts+=( "host=${CT_BUILD}" )
-    core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    core_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
-    core_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
-    core_opts+=( "lang_list=c" )
-
-    # Different conditions are at stake here:
-    #   - In case the threading model is NPTL, we need a shared-capable core
-    #     gcc; in all other cases, we need a static-only core gcc.
-    #   - In case the threading model is NPTL or win32, or gcc is 4.3 or
-    #     later, we need to build libgcc
-    case "${CT_THREADS}" in
-        nptl)
-            core_opts+=( "mode=shared" )
-            core_opts+=( "build_libgcc=yes" )
-            ;;
-        win32)
-            core_opts+=( "mode=static" )
-            core_opts+=( "build_libgcc=yes" )
-            ;;
-        *)
-            core_opts+=( "mode=static" )
-            if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
-                core_opts+=( "build_libgcc=yes" )
-            fi
-            ;;
-    esac
-
-    CT_DoStep INFO "Installing pass-2 core C compiler"
-    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-core-pass-2"
-
-    do_cc_core_backend "${core_opts[@]}"
-
-    CT_Popd
-    CT_EndStep
-}
-
-#------------------------------------------------------------------------------
-# Build core gcc
-# This function is used to build the core C compiler.
-# Usage: do_cc_core_backend param=value [...]
-#   Parameter           : Definition                                : Type      : Default
-#   mode                : build a 'static', 'shared' or 'baremetal' : string    : (none)
-#   host                : the machine the core will run on          : tuple     : (none)
-#   prefix              : dir prefix to install into                : dir       : (none)
-#   complibs            : dir where complibs are isntalled          : dir       : (none)
-#   lang_list           : the list of languages to build            : string    : (empty)
-#   build_libgcc        : build libgcc or not                       : bool      : no
-#   build_libstdcxx     : build libstdc++ or not                    : bool      : no
-#   build_staticlinked  : build statically linked or not            : bool      : no
-#   build_manuals       : whether to build manuals or not           : bool      : no
-#   cflags              : cflags to use                             : string    : (empty)
-#   ldflags             : ldflags to use                            : string    : (empty)
-# Usage: do_cc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no]
-do_cc_core_backend() {
-    local mode
-    local build_libgcc=no
-    local build_libstdcxx=no
-    local build_staticlinked=no
-    local build_manuals=no
-    local host
-    local prefix
-    local complibs
-    local lang_list
-    local cflags
-    local ldflags
-    local tmp
-    local -a host_libstdcxx_flags
-    local -a extra_config
-    local -a core_LDFLAGS
-    local -a core_targets
-    local arg
-
-    for arg in "$@"; do
-        eval "${arg// /\\ }"
-    done
-
-    CT_DoLog EXTRA "Configuring gcc"
-
-    case "${mode}" in
-        static)
-            extra_config+=("--with-newlib")
-            extra_config+=("--enable-threads=no")
-            extra_config+=("--disable-shared")
-            copy_headers=y  # For baremetal, as there's no headers to copy,
-                            # we copy an empty directory. So, who cares?
-            ;;
-        shared)
-            extra_config+=("--enable-shared")
-            copy_headers=y
-            ;;
-        baremetal)
-            extra_config+=("--with-newlib")
-            extra_config+=("--enable-threads=no")
-            extra_config+=("--disable-shared")
-            copy_headers=n
-            ;;
-        *)
-            CT_Abort "Internal Error: 'mode' must be one of: 'static', 'shared' or 'baremetal', not '${mode:-(empty)}'"
-            ;;
-    esac
-
-    if [ "${CT_CC_GCC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
-        # Bare metal delivers the core compiler as final compiler, so add version info and bugurl
-        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
-        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
-    fi
-
-    if [ "${copy_headers}" = "y" ]; then
-        CT_DoLog DEBUG "Copying headers to install area of bootstrap gcc, so it can build libgcc2"
-        CT_DoExecLog ALL cp -a "${CT_HEADERS_DIR}" "${prefix}/${CT_TARGET}/include"
-    fi
-
-    for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
-        eval tmp="\${CT_ARCH_WITH_${tmp}}"
-        if [ -n "${tmp}" ]; then
-            extra_config+=("${tmp}")
-        fi
-    done
-    if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
-        extra_config+=("--enable-__cxa_atexit")
-    else
-        extra_config+=("--disable-__cxa_atexit")
-    fi
-
-    core_LDFLAGS+=("${ldflags}")
-
-    # *** WARNING ! ***
-    # Keep this full if-else-if-elif-fi-fi block in sync
-    # with the same block in do_cc, below.
-    if [ "${build_staticlinked}" = "yes" ]; then
-        core_LDFLAGS+=("-static")
-        host_libstdcxx_flags+=("-static-libgcc")
-        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
-        host_libstdcxx_flags+=("-lm")
-        # Companion libraries are build static (eg !shared), so
-        # the libstdc++ is not pulled automatically, although it
-        # is needed. Shoe-horn it in our LDFLAGS
-        # Ditto libm on some Fedora boxen
-        core_LDFLAGS+=("-lstdc++")
-        core_LDFLAGS+=("-lm")
-    else
-        if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
-            # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
-            # build script
-            # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
-            #       see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
-            host_libstdcxx_flags+=("-static-libgcc")
-            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
-            host_libstdcxx_flags+=("-lm")
-        elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
-            # When companion libraries are build static (eg !shared),
-            # the libstdc++ is not pulled automatically, although it
-            # is needed. Shoe-horn it in our LDFLAGS
-            # Ditto libm on some Fedora boxen
-            core_LDFLAGS+=("-lstdc++")
-            core_LDFLAGS+=("-lm")
-        fi
-    fi
-
-    if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
-        extra_config+=("--with-gmp=${complibs}")
-        extra_config+=("--with-mpfr=${complibs}")
-    fi
-    if [ "${CT_CC_GCC_USE_MPC}" = "y" ]; then
-        extra_config+=("--with-mpc=${complibs}")
-    fi
-    if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
-        if [ "${CT_PPL}" = "y" ]; then
-            extra_config+=("--with-ppl=${complibs}")
-            # With PPL 0.11+, also pull libpwl if needed
-            if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
-                host_libstdcxx_flags+=("-L${complibs}/lib")
-                host_libstdcxx_flags+=("-lpwl")
-            fi
-        fi
-        if [ "${CT_ISL}" = "y" ]; then
-            extra_config+=("--with-isl=${complibs}")
-        fi
-        extra_config+=("--with-cloog=${complibs}")
-    elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
-        extra_config+=("--with-ppl=no")
-        extra_config+=("--with-isl=no")
-        extra_config+=("--with-cloog=no")
-    fi
-    if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then
-        extra_config+=("--with-libelf=${complibs}")
-        extra_config+=("--enable-lto")
-    elif [ "${CT_CC_GCC_HAS_LTO}" = "y" ]; then
-        extra_config+=("--with-libelf=no")
-        extra_config+=("--disable-lto")
-    fi
-
-    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
-        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
-    fi
-
-    if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
-        extra_config+=("--enable-target-optspace")
-    fi
-
-    case "${CT_CC_GCC_LDBL_128}" in
-        y)  extra_config+=("--with-long-double-128");;
-        m)  ;;
-        "") extra_config+=("--without-long-double-128");;
-    esac
-
-    if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then
-        extra_config+=( --enable-linker-build-id )
-    fi
-
-    case "${CT_CC_GCC_LNK_HASH_STYLE}" in
-        "") ;;
-        *)  extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );;
-    esac
-
-    case "${CT_ARCH}" in
-        mips)
-            case "${CT_CC_GCC_mips_llsc}" in
-                y)  extra_config+=( --with-llsc );;
-                m)  ;;
-                *)  extra_config+=( --without-llsc );;
-            esac
-            case "${CT_CC_GCC_mips_synci}" in
-                y)  extra_config+=( --with-synci );;
-                m)  ;;
-                *)  extra_config+=( --without-synci );;
-            esac
-            if [ "${CT_CC_GCC_mips_plt}" ]; then
-                extra_config+=( --with-mips-plt )
-            fi
-            ;; # ARCH is mips
-    esac
-
-    extra_config+=(--disable-libgomp)
-    extra_config+=(--disable-libmudflap)
-
-    [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
-
-    [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ] && extra_config+=("--disable-libstdcxx-pch")
-
-    if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
-        extra_config+=("--with-system-zlib")
-    fi
-
-    if [ "${CT_MULTILIB}" = "y" ]; then
-        extra_config+=("--enable-multilib")
-    else
-        extra_config+=("--disable-multilib")
-    fi
-
-    CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
-
-    # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
-    CT_DoExecLog CFG                                \
-    CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
-    CFLAGS="${cflags}"                              \
-    LDFLAGS="${core_LDFLAGS[*]}"                    \
-    "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure"  \
-        --build=${CT_BUILD}                         \
-        --host=${host}                              \
-        --target=${CT_TARGET}                       \
-        --prefix="${prefix}"                        \
-        --with-local-prefix="${CT_SYSROOT_DIR}"     \
-        --disable-libmudflap                        \
-        ${CC_CORE_SYSROOT_ARG}                      \
-        "${extra_config[@]}"                        \
-        --enable-languages="${lang_list}"           \
-        "${CT_CC_CORE_EXTRA_CONFIG_ARRAY[@]}"
-
-    if [ "${build_libgcc}" = "yes" ]; then
-        # HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver or
-        # gcc/config/t-libunwind so -lc is removed from the link for
-        # libgcc_s.so, as we do not have a target -lc yet.
-        # This is not as ugly as it appears to be ;-) All symbols get resolved
-        # during the glibc build, and we provide a proper libgcc_s.so for the
-        # cross toolchain during the final gcc build.
-        #
-        # As we cannot modify the source tree, nor override SHLIB_LC itself
-        # during configure or make, we have to edit the resultant
-        # gcc/libgcc.mk itself to remove -lc from the link.
-        # This causes us to have to jump through some hoops...
-        #
-        # To produce libgcc.mk to edit we firstly require libiberty.a,
-        # so we configure then build it.
-        # Next we have to configure gcc, create libgcc.mk then edit it...
-        # So much easier if we just edit the source tree, but hey...
-        if [ ! -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
-            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libiberty
-            CT_DoExecLog ALL make ${JOBSFLAGS} -C libiberty libiberty.a
-            CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp
-            CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp
-        else
-            CT_DoExecLog CFG make ${JOBSFLAGS} configure-gcc configure-libcpp configure-build-libiberty
-            CT_DoExecLog ALL make ${JOBSFLAGS} all-libcpp all-build-libiberty
-        fi
-        # HACK: gcc-4.2 uses libdecnumber to build libgcc.mk, so build it here.
-        if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/libdecnumber" ]; then
-            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libdecnumber
-            CT_DoExecLog ALL make ${JOBSFLAGS} -C libdecnumber libdecnumber.a
-        fi
-        # HACK: gcc-4.8 uses libbacktrace to make libgcc.mvars, so make it here.
-        if [ -d "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/libbacktrace" ]; then
-            CT_DoExecLog CFG make ${JOBSFLAGS} configure-libbacktrace
-            CT_DoExecLog ALL make ${JOBSFLAGS} -C libbacktrace
-        fi
-
-        # Starting with GCC 4.3, libgcc.mk is no longer built,
-        # and libgcc.mvars is used instead.
-
-        if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
-            libgcc_rule="libgcc.mvars"
-            core_targets=( gcc target-libgcc )
-        else
-            libgcc_rule="libgcc.mk"
-            core_targets=( gcc )
-        fi
-
-        # On bare metal and canadian build the host-compiler is used when
-        # actually the build-system compiler is required. Choose the correct
-        # compilers for canadian build and use the defaults on other
-        # configurations.
-        if [ "${CT_BARE_METAL},${CT_CANADIAN}" = "y,y" ]; then
-            repair_cc="CC_FOR_BUILD=${CT_BUILD}-gcc \
-                       CXX_FOR_BUILD=${CT_BUILD}-g++ \
-                       GCC_FOR_TARGET=${CT_TARGET}-gcc"
-        else
-            repair_cc=""
-        fi
-
-        CT_DoExecLog ALL make ${JOBSFLAGS} -C gcc ${libgcc_rule} \
-                              ${repair_cc}
-        sed -r -i -e 's@-lc@@g' gcc/${libgcc_rule}
-    else # build_libgcc
-        core_targets=( gcc )
-    fi   # ! build libgcc
-    if [    "${build_libstdcxx}" = "yes"    \
-         -a "${CT_CC_LANG_CXX}"  = "y"      \
-       ]; then
-        core_targets+=( target-libstdc++-v3 )
-    fi
-
-    CT_DoLog EXTRA "Building gcc"
-    CT_DoExecLog ALL make ${JOBSFLAGS} "${core_targets[@]/#/all-}"
-
-    CT_DoLog EXTRA "Installing gcc"
-    CT_DoExecLog ALL make ${JOBSFLAGS} "${core_targets[@]/#/install-}"
-
-    if [ "${build_manuals}" = "yes" ]; then
-        CT_DoLog EXTRA "Building the GCC manuals"
-        CT_DoExecLog ALL make pdf html
-        CT_DoLog EXTRA "Installing the GCC manuals"
-        CT_DoExecLog ALL make install-{pdf,html}-gcc
-    fi
-
-    # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
-    # to call the C compiler with the same, somewhat canonical name.
-    # check whether compiler has an extension
-    file="$( ls -1 "${prefix}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )"
-    [ -z "${file}" ] || ext=".${file##*.}"
-    CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${prefix}/bin/${CT_TARGET}-cc${ext}"
-
-    if [ "${CT_MULTILIB}" = "y" ]; then
-        if [ "${CT_CANADIAN}" = "y" -a "${mode}" = "baremetal" \
-             -a "${host}" = "${CT_HOST}" ]; then
-            CT_DoLog WARN "Canadian Cross unable to confirm multilibs configured correctly"
-        else
-            multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib   \
-                           |tail -n +2 ) )
-            if [ ${#multilibs[@]} -ne 0 ]; then
-                CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):"
-                for i in "${multilibs[@]}"; do
-                    dir="${i%%;*}"
-                    flags="${i#*;}"
-                    CT_DoLog EXTRA "   ${flags//@/ -}  -->  ${dir}/"
-                done
-            else
-                CT_DoLog WARN "gcc configured for multilib, but none available"
-           fi
-        fi
-    fi
-}
-
-#------------------------------------------------------------------------------
-# Build complete gcc to run on build
-do_cc_for_build() {
-    local -a build_final_opts
-    local build_final_backend
-
-    # In case we're canadian or cross-native, it seems that a
-    # real, complete compiler is needed?!? WTF? Sigh...
-    # Otherwise, there is nothing to do.
-    case "${CT_TOOLCHAIN_TYPE}" in
-        native|cross)   return 0;;
-    esac
-
-    build_final_opts+=( "host=${CT_BUILD}" )
-    build_final_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    build_final_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" )
-    build_final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
-    if [ "${CT_BARE_METAL}" = "y" ]; then
-        # In the tests I've done, bare-metal was not impacted by the
-        # lack of such a compiler, but better safe than sorry...
-        build_final_opts+=( "mode=baremetal" )
-        build_final_opts+=( "build_libgcc=yes" )
-        build_final_opts+=( "build_libstdcxx=yes" )
-        if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
-            build_final_opts+=( "build_staticlinked=yes" )
-        fi
-        build_final_backend=do_cc_core_backend
-    else
-        build_final_backend=do_cc_backend
-    fi
-
-    CT_DoStep INFO "Installing final compiler for build"
-    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final-build-${CT_BUILD}"
-
-    "${build_final_backend}" "${build_final_opts[@]}"
-
-    CT_Popd
-    CT_EndStep
-}
-
-#------------------------------------------------------------------------------
-# Build final gcc to run on host
-do_cc_for_host() {
-    local -a final_opts
-    local final_backend
-
-    final_opts+=( "host=${CT_HOST}" )
-    final_opts+=( "prefix=${CT_PREFIX_DIR}" )
-    final_opts+=( "complibs=${CT_HOST_COMPLIBS_DIR}" )
-    final_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
-    final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
-    final_opts+=( "lang_list=$( cc_gcc_lang_list )" )
-    if [ "${CT_BUILD_MANUALS}" = "y" ]; then
-        final_opts+=( "build_manuals=yes" )
-    fi
-    if [ "${CT_BARE_METAL}" = "y" ]; then
-        final_opts+=( "mode=baremetal" )
-        final_opts+=( "build_libgcc=yes" )
-        final_opts+=( "build_libstdcxx=yes" )
-        if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
-            final_opts+=( "build_staticlinked=yes" )
-        fi
-        final_backend=do_cc_core_backend
-    else
-        final_backend=do_cc_backend
-    fi
-
-    CT_DoStep INFO "Installing final compiler"
-    CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-final"
-
-    "${final_backend}" "${final_opts[@]}"
-
-    CT_Popd
-    CT_EndStep
-}
-
-#------------------------------------------------------------------------------
-# Build the final gcc
-# Usage: do_cc_backend param=value [...]
-#   Parameter     : Definition                          : Type      : Default
-#   host          : the host we run onto                : tuple     : (none)
-#   prefix        : the runtime prefix                  : dir       : (none)
-#   complibs      : the companion libraries prefix      : dir       : (none)
-#   cflags        : cflags to use                       : string    : (empty)
-#   ldflags       : ldflags to use                      : string    : (empty)
-#   lang_list     : the list of languages to build      : string    : (empty)
-#   build_manuals : whether to build manuals or not     : bool      : no
-do_cc_backend() {
-    local host
-    local prefix
-    local complibs
-    local cflags
-    local ldflags
-    local lang_list
-    local build_manuals
-    local -a host_libstdcxx_flags
-    local -a extra_config
-    local -a final_LDFLAGS
-    local tmp
-    local arg
-
-    for arg in "$@"; do
-        eval "${arg// /\\ }"
-    done
-
-    CT_DoLog EXTRA "Configuring gcc"
-
-    # Enable selected languages
-    extra_config+=("--enable-languages=${lang_list}")
-
-    for tmp in ARCH ABI CPU TUNE FPU FLOAT; do
-        eval tmp="\${CT_ARCH_WITH_${tmp}}"
-        if [ -n "${tmp}" ]; then
-            extra_config+=("${tmp}")
-        fi
-    done
-
-    [ "${CT_SHARED_LIBS}" = "y" ] || extra_config+=("--disable-shared")
-    if [ "${CT_CC_GCC_HAS_PKGVERSION_BUGURL}" = "y" ]; then
-        extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
-        [ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")
-    fi
-    case "${CT_CC_GCC_SJLJ_EXCEPTIONS}" in
-        y)  extra_config+=("--enable-sjlj-exceptions");;
-        m)  ;;
-        "") extra_config+=("--disable-sjlj-exceptions");;
-    esac
-    if [ "${CT_CC_CXA_ATEXIT}" = "y" ]; then
-        extra_config+=("--enable-__cxa_atexit")
-    else
-        extra_config+=("--disable-__cxa_atexit")
-    fi
-    if [ -n "${CT_CC_ENABLE_CXX_FLAGS}" ]; then
-        extra_config+=("--enable-cxx-flags=${CT_CC_ENABLE_CXX_FLAGS}")
-    fi
-    if [ "${CT_CC_GCC_LIBMUDFLAP}" = "y" ]; then
-        extra_config+=(--enable-libmudflap)
-    else
-        extra_config+=(--disable-libmudflap)
-    fi
-    if [ "${CT_CC_GCC_LIBGOMP}" = "y" ]; then
-        extra_config+=(--enable-libgomp)
-    else
-        extra_config+=(--disable-libgomp)
-    fi
-    if [ "${CT_CC_GCC_LIBSSP}" = "y" ]; then
-        extra_config+=(--enable-libssp)
-    else
-        extra_config+=(--disable-libssp)
-    fi
-    if [ "${CT_CC_GCC_HAS_LIBQUADMATH}" = "y" ]; then
-        if [ "${CT_CC_GCC_LIBQUADMATH}" = "y" ]; then
-            extra_config+=(--enable-libquadmath)
-            extra_config+=(--enable-libquadmath-support)
-        else
-            extra_config+=(--disable-libquadmath)
-            extra_config+=(--disable-libquadmath-support)
-        fi
-    fi
-
-    final_LDFLAGS+=("${ldflags}")
-
-    # *** WARNING ! ***
-    # Keep this full if-else-if-elif-fi-fi block in sync
-    # with the same block in do_cc_core, above.
-    if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
-        final_LDFLAGS+=("-static")
-        host_libstdcxx_flags+=("-static-libgcc")
-        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
-        host_libstdcxx_flags+=("-lm")
-        # Companion libraries are build static (eg !shared), so
-        # the libstdc++ is not pulled automatically, although it
-        # is needed. Shoe-horn it in our LDFLAGS
-        # Ditto libm on some Fedora boxen
-        final_LDFLAGS+=("-lstdc++")
-        final_LDFLAGS+=("-lm")
-    else
-        if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
-            # this is from CodeSourcery arm-2010q1-202-arm-none-linux-gnueabi.src.tar.bz2
-            # build script
-            # INFO: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
-            #       see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
-            host_libstdcxx_flags+=("-static-libgcc")
-            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
-            host_libstdcxx_flags+=("-lm")
-        elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
-            # When companion libraries are build static (eg !shared),
-            # the libstdc++ is not pulled automatically, although it
-            # is needed. Shoe-horn it in our LDFLAGS
-            # Ditto libm on some Fedora boxen
-            final_LDFLAGS+=("-lstdc++")
-            final_LDFLAGS+=("-lm")
-        fi
-    fi
-
-    if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
-        extra_config+=("--with-gmp=${complibs}")
-        extra_config+=("--with-mpfr=${complibs}")
-    fi
-    if [ "${CT_CC_GCC_USE_MPC}" = "y" ]; then
-        extra_config+=("--with-mpc=${complibs}")
-    fi
-    if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
-        if [ "${CT_PPL}" = "y" ]; then
-            extra_config+=("--with-ppl=${complibs}")
-            # With PPL 0.11+, also pull libpwl if needed
-            if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
-                host_libstdcxx_flags+=("-L${complibs}/lib")
-                host_libstdcxx_flags+=("-lpwl")
-            fi
-        fi
-        if [ "${CT_ISL}" = "y" ]; then
-            extra_config+=("--with-isl=${complibs}")
-        fi
-        extra_config+=("--with-cloog=${complibs}")
-    elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
-        extra_config+=("--with-ppl=no")
-        extra_config+=("--with-isl=no")
-        extra_config+=("--with-cloog=no")
-    fi
-    if [ "${CT_CC_GCC_USE_LTO}" = "y" ]; then
-        extra_config+=("--with-libelf=${complibs}")
-    elif [ "${CT_CC_GCC_HAS_LTO}" = "y" ]; then
-        extra_config+=("--with-libelf=no")
-    fi
-
-    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
-        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
-    fi
-
-    if [ "${CT_THREADS}" = "none" ]; then
-        extra_config+=("--disable-threads")
-        if [ "${CT_CC_GCC_4_2_or_later}" = y ]; then
-            CT_Test "Disabling libgomp for no-thread gcc>=4.2" "${CT_CC_GCC_LIBGOMP}" = "Y"
-            extra_config+=("--disable-libgomp")
-        fi
-    else
-        if [ "${CT_THREADS}" = "win32" ]; then
-            extra_config+=("--enable-threads=win32")
-            extra_config+=("--disable-win32-registry")
-        else
-            extra_config+=("--enable-threads=posix")
-        fi
-    fi
-
-    if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
-        extra_config+=("--enable-target-optspace")
-    fi
-    if [ "${CT_CC_GCC_DISABLE_PCH}" = "y" ]; then
-        extra_config+=("--disable-libstdcxx-pch")
-    fi
-
-    case "${CT_CC_GCC_LDBL_128}" in
-        y)  extra_config+=("--with-long-double-128");;
-        m)  ;;
-        "") extra_config+=("--without-long-double-128");;
-    esac
-
-    if [ "${CT_CC_GCC_BUILD_ID}" = "y" ]; then
-        extra_config+=( --enable-linker-build-id )
-    fi
-
-    case "${CT_CC_GCC_LNK_HASH_STYLE}" in
-        "") ;;
-        *)  extra_config+=( "--with-linker-hash-style=${CT_CC_GCC_LNK_HASH_STYLE}" );;
-    esac
-
-    if [ "${CT_CC_GCC_ENABLE_PLUGINS}" = "y" ]; then
-        extra_config+=( --enable-plugin )
-    fi
-    if [ "${CT_CC_GCC_GOLD}" = "y" ]; then
-        extra_config+=( --enable-gold )
-    fi
-
-    case "${CT_ARCH}" in
-        mips)
-            case "${CT_CC_GCC_mips_llsc}" in
-                y)  extra_config+=( --with-llsc );;
-                m)  ;;
-                *)  extra_config+=( --without-llsc );;
-            esac
-            case "${CT_CC_GCC_mips_synci}" in
-                y)  extra_config+=( --with-synci );;
-                m)  ;;
-                *)  extra_config+=( --without-synci );;
-            esac
-            if [ "${CT_CC_GCC_mips_plt}" ]; then
-                extra_config+=( --with-mips-plt )
-            fi
-            ;; # ARCH is mips
-    esac
-
-    [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
-
-    if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
-        extra_config+=("--with-system-zlib")
-    fi
-
-    if [ "${CT_MULTILIB}" = "y" ]; then
-        extra_config+=("--enable-multilib")
-    else
-        extra_config+=("--disable-multilib")
-    fi
-
-    CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'"
-
-    CT_DoExecLog CFG                                \
-    CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
-    CFLAGS="${cflags}"                              \
-    LDFLAGS="${final_LDFLAGS[*]}"                   \
-    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"         \
-    CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"       \
-    LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}"       \
-    "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/configure"  \
-        --build=${CT_BUILD}                         \
-        --host=${host}                              \
-        --target=${CT_TARGET}                       \
-        --prefix="${prefix}"                        \
-        ${CC_SYSROOT_ARG}                           \
-        "${extra_config[@]}"                        \
-        --with-local-prefix="${CT_SYSROOT_DIR}"     \
-        --enable-c99                                \
-        --enable-long-long                          \
-        "${CT_CC_EXTRA_CONFIG_ARRAY[@]}"
-
-    if [ "${CT_CANADIAN}" = "y" ]; then
-        CT_DoLog EXTRA "Building libiberty"
-        CT_DoExecLog ALL make ${JOBSFLAGS} all-build-libiberty
-    fi
-
-    CT_DoLog EXTRA "Building gcc"
-    CT_DoExecLog ALL make ${JOBSFLAGS} all
-
-    CT_DoLog EXTRA "Installing gcc"
-    CT_DoExecLog ALL make ${JOBSFLAGS} install
-
-    if [ "${build_manuals}" = "yes" ]; then
-        CT_DoLog EXTRA "Building the GCC manuals"
-        CT_DoExecLog ALL make pdf html
-        CT_DoLog EXTRA "Installing the GCC manuals"
-        CT_DoExecLog ALL make install-{pdf,html}-gcc
-    fi
-
-    # Create a symlink ${CT_TARGET}-cc to ${CT_TARGET}-gcc to always be able
-    # to call the C compiler with the same, somewhat canonical name.
-    # check whether compiler has an extension
-    file="$( ls -1 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-gcc."* 2>/dev/null || true )"
-    [ -z "${file}" ] || ext=".${file##*.}"
-    CT_DoExecLog ALL ln -sfv "${CT_TARGET}-gcc${ext}" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-cc${ext}"
-
-    if [ "${CT_MULTILIB}" = "y" ]; then
-        if [ "${CT_CANADIAN}" = "y" ]; then
-            CT_DoLog WARN "Canadian Cross unable to confirm multilibs configured correctly"
-        else
-            multilibs=( $( "${prefix}/bin/${CT_TARGET}-gcc" -print-multi-lib \
-                           |tail -n +2 ) )
-            if [ ${#multilibs[@]} -ne 0 ]; then
-                CT_DoLog EXTRA "gcc configured with these multilibs (besides the default):"
-                for i in "${multilibs[@]}"; do
-                    dir="${i%%;*}"
-                    flags="${i#*;}"
-                    CT_DoLog EXTRA "   ${flags//@/ -}  -->  ${dir}/"
-                done
-            else
-                CT_DoLog WARN "gcc configured for multilib, but none available"
-            fi
-        fi
-    fi
-}
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/debug/300-gdb.sh
--- a/scripts/build/debug/300-gdb.sh	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/build/debug/300-gdb.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -181,11 +181,11 @@ 
         if [ "${CT_GDB_INSTALL_GDBINIT}" = "y" ]; then
             CT_DoLog EXTRA "Installing '.gdbinit' template"
             # See in scripts/build/internals.sh for why we do this
-            if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
-                gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
+            if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
+                gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
             else
-                gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
-                                   "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c"   \
+                gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;'     \
+                                   "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c"   \
                              )
             fi
             ${sed} -r                                               \
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/internals.sh
--- a/scripts/build/internals.sh	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/build/internals.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -28,33 +28,35 @@ 
             CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args}         \
                              "${CT_TARGET}/debug-root/usr/bin/gdbserver"
         fi
-        # We can not use the version in CT_CC_VERSION because
-        # of the Linaro stuff. So, harvest the version string
-        # directly from the gcc sources...
-        # All gcc 4.x seem to have the version in gcc/BASE-VER
-        # while version prior to 4.x have the version in gcc/version.c
-        # Of course, here is not the better place to do that...
-        if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
-            gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
-        else
-            gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
-                               "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c"   \
-                         )
+        if [ "${CT_CC_gcc}" = "y" ]; then
+            # We can not use the version in CT_CC_GCC_VERSION because
+            # of the Linaro stuff. So, harvest the version string
+            # directly from the gcc sources...
+            # All gcc 4.x seem to have the version in gcc/BASE-VER
+            # while version prior to 4.x have the version in gcc/version.c
+            # Of course, here is not the better place to do that...
+            if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" ]; then
+                gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/BASE-VER" )
+            else
+                gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;'     \
+                                   "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/version.c"   \
+                             )
+            fi
+            for _t in "bin/${CT_TARGET}-"*                                      \
+                      "${CT_TARGET}/bin/"*                                      \
+                      "libexec/gcc/${CT_TARGET}/${gcc_version}/"*               \
+                      "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \
+            ; do
+                _type="$( file "${_t}" |cut -d ' ' -f 2- )"
+                case "${_type}" in
+                    *script*executable*)
+                        ;;
+                    *executable*)
+                        CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
+                        ;;
+                esac
+            done
         fi
-        for _t in "bin/${CT_TARGET}-"*                                      \
-                  "${CT_TARGET}/bin/"*                                      \
-                  "libexec/gcc/${CT_TARGET}/${gcc_version}/"*               \
-                  "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \
-        ; do
-            _type="$( file "${_t}" |cut -d ' ' -f 2- )"
-            case "${_type}" in
-                *script*executable*)
-                    ;;
-                *executable*)
-                    CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
-                    ;;
-            esac
-        done
         CT_Popd
     fi
 
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/build/test_suite/gcc.sh
--- a/scripts/build/test_suite/gcc.sh	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/build/test_suite/gcc.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -15,10 +15,10 @@ 
     CT_DoStep INFO "Installing GCC test suite"
 
     CT_DoExecLog ALL mkdir -p "${CT_TEST_SUITE_DIR}/gcc"
-    CT_DoExecLog ALL cp -av "${CT_LIB_DIR}/contrib/gcc-test-suite/default.cfg"  \
-                            "${CT_LIB_DIR}/contrib/gcc-test-suite/Makefile"     \
-                            "${CT_LIB_DIR}/contrib/gcc-test-suite/README"       \
-                            "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/testsuite"  \
+    CT_DoExecLog ALL cp -av "${CT_LIB_DIR}/contrib/gcc-test-suite/default.cfg"      \
+                            "${CT_LIB_DIR}/contrib/gcc-test-suite/Makefile"         \
+                            "${CT_LIB_DIR}/contrib/gcc-test-suite/README"           \
+                            "${CT_SRC_DIR}/gcc-${CT_CC_GCC_VERSION}/gcc/testsuite"  \
                             "${CT_TEST_SUITE_DIR}/gcc"
 
     CT_DoExecLog ALL sed -i -r -e "s/@@DG_TARGET@@/${CT_TARGET}/g;"     \
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/crosstool-NG.sh.in	Wed Dec 11 21:28:37 2013 +0100
@@ -140,7 +140,7 @@ 
 . "${CT_LIB_DIR}/scripts/build/companion_libs.sh"
 . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh"
 . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
-. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
+. "${CT_LIB_DIR}/scripts/build/cc.sh"
 . "${CT_LIB_DIR}/scripts/build/debug.sh"
 . "${CT_LIB_DIR}/scripts/build/test_suite.sh"
 
@@ -162,8 +162,8 @@ 
 # Put user-supplied flags at the end, so that they take precedence.
 CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
 CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
-CT_CC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
-CT_CC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_EXTRA_CONFIG_ARRAY[@]}" )
+CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_CORE_EXTRA_CONFIG} "${CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY[@]}" )
+CT_CC_GCC_EXTRA_CONFIG_ARRAY=( ${CT_ARCH_CC_EXTRA_CONFIG} "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" )
 
 # Compute the package version string
 CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOLCHAIN_PKGVERSION}}"
@@ -545,8 +545,8 @@ 
         CT_EndStep
     fi
 
-    if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then
-        CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_STATIC_LIBSTDCXX)"
+    if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then
+        CT_DoStep DEBUG "Checking that gcc can statically link libstdc++ (CT_CC_GCC_STATIC_LIBSTDCXX)"
         CT_DoLog DEBUG "You may need to ensure that libstdc++.a is installed on your system"
         CT_DoExecLog DEBUG "${CT_HOST}-gcc" ${CT_CFLAGS_FOR_HOST} ${CT_LDFLAGS_FOR_HOST} "${testc}" -static -lstdc++ -o "${gccout}"
         rm -f "${gccout}"
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/gen_in_frags.sh
--- a/scripts/gen_in_frags.sh	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/gen_in_frags.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -138,6 +138,9 @@ 
         _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
         printf 'menuconfig %s_%s\n' "${cfg_prefix}" "${_entry}"
         printf '    bool\n'
+        if "${grep}" -E '^## default' ${file} >/dev/null 2>&1; then
+            "${sed}" -r -e '/^## default ?/!d; s/^## default ?/    default /;' ${file} 2>/dev/null
+        fi
         printf '    prompt "%s"\n' "${entry}"
         "${sed}" -r -e '/^## depends on /!d; s/^## /    /;' ${file} 2>/dev/null
         "${sed}" -r -e '/^## select /!d; s/^## /    /;' ${file} 2>/dev/null
diff -r 7e569a9cb5fd -r cc545a5c1896 scripts/showSamples.sh
--- a/scripts/showSamples.sh	Sat Nov 16 18:14:45 2013 +0100
+++ b/scripts/showSamples.sh	Wed Dec 11 21:28:37 2013 +0100
@@ -76,16 +76,24 @@ 
             [ -z "${CT_LIBELF}" -a -z "${CT_LIBELF_TARGET}" ] || printf " libelf-%s"    "${CT_LIBELF_VERSION}"
             [ -z "${complibs}"  ] || printf "\n"
             printf  "    %-*s : %s\n" ${width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
-            printf  "    %-*s : %s" ${width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
-            [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
-            [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
-            [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
-            [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
-            [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
-            [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
-            [ "${CT_CC_LANG_GOLANG}" = "y"  ] && printf ",Go"
-            [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
-            printf ")\n"
+            printf  "    %-*s :" ${width} "C compilers"
+            for cc in $(compgen -A variable | sed -n 's/^CT_CC_\([^_]\+\)_VERSION$/\1/p'); do
+                cc_variable=CT_CC_${cc}_VERSION
+                version=${!cc_variable}
+                compiler=$(echo $cc | sed -E ''| awk '{print tolower($0)}')
+                printf " $compiler-$version"
+            done
+            printf "\n"
+            printf  "    %-*s : %s" ${width} "Languages" "C"
+            [ "${CT_CC_LANG_CXX}" = "y"     ] && printf " C++"
+            [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf " Fortran"
+            [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf " Java"
+            [ "${CT_CC_LANG_ADA}" = "y"     ] && printf " ADA"
+            [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf " Objective-C"
+            [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf " Objective-C++"
+            [ "${CT_CC_LANG_GOLANG}" = "y"  ] && printf " Go"
+            [ -n "${CT_CC_LANG_OTHERS}"     ] && printf " ${CT_CC_LANG_OTHERS}"
+            printf "\n"
             printf  "    %-*s : %s (threads: %s)\n" ${width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}" "${CT_THREADS}"
             printf  "    %-*s :" ${width} "Tools"
             [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
@@ -121,7 +129,7 @@ 
         fi
         printf "|  ${CT_BINUTILS_VERSION}  "
         printf "|  ''${CT_CC}''  "
-        printf "|  ${CT_CC_VERSION}  "
+        printf "|  ${CT_CC_GCC_VERSION}  "
         printf "|  ''${CT_LIBC}''  |"
         if [ "${CT_LIBC}" != "none" ]; then
             printf "  ${CT_LIBC_VERSION}  "