cc/gcc: baremetal requires a two-pass process
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jun 13 23:38:37 2010 +0200 (2010-06-13)
changeset 1983198a5a6e5239
parent 1982 63cee3d5ab85
child 1984 95b4a458fd60
cc/gcc: baremetal requires a two-pass process

Here, we implement a highly ugly hack. I'm not proud of that one...

To build the libstdc++ library, the compiler requires the C library. In
case we build for non-baremetal, this is normally handled by the final
step, later.

But in the case of bare-metal, we never go through the final step (because
it does not work, and it seems complex enough to make it work), so the
baremetal compilers are issued out of the core step.
scripts/build/cc/gcc.sh
     1.1 --- a/scripts/build/cc/gcc.sh	Sun Jun 13 23:45:29 2010 +0200
     1.2 +++ b/scripts/build/cc/gcc.sh	Sun Jun 13 23:38:37 2010 +0200
     1.3 @@ -47,7 +47,7 @@
     1.4      # In case we're not bare metal, and we're NPTL, build the static core gcc.
     1.5      # In any other case, do nothing.
     1.6      case "${CT_BARE_METAL},${CT_CANADIAN},${CT_THREADS}" in
     1.7 -        y,*,*)  do_cc_core mode=baremetal build_libgcc=yes;;
     1.8 +        y,*,*)  do_cc_core mode=static;;
     1.9          ,y,*)   ;;
    1.10          ,,nptl) do_cc_core mode=static;;
    1.11          *)      ;;
    1.12 @@ -63,8 +63,8 @@
    1.13      # In any other case, build the static core gcc and, if using gcc-4.3+,
    1.14      # also build the target libgcc.
    1.15      case "${CT_BARE_METAL},${CT_CANADIAN},${CT_THREADS}" in
    1.16 -        y,*,*)   ;;
    1.17 -        ,y,*)    ;;
    1.18 +        y,*,*)  do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes;;
    1.19 +        ,y,*)   ;;
    1.20          ,,nptl)
    1.21              do_cc_core mode=shared build_libgcc=yes
    1.22              ;;
    1.23 @@ -83,10 +83,12 @@
    1.24  # with or without the target libgcc. We need to know wether:
    1.25  #  - we're building static, shared or bare metal: mode=[static|shared|baremetal]
    1.26  #  - we need to build libgcc or not             : build_libgcc=[yes|no]     (default: no)
    1.27 +#  - we need to build libstdc++ or not          : build_libstdcxx=[yes|no]  (default: no)
    1.28  # Usage: do_cc_core_static mode=[static|shared|baremetal] build_libgcc=[yes|no]
    1.29  do_cc_core() {
    1.30      local mode
    1.31      local build_libgcc=no
    1.32 +    local build_libstdcxx=no
    1.33      local core_prefix_dir
    1.34      local lang_opt
    1.35      local tmp
    1.36 @@ -106,7 +108,8 @@
    1.37              extra_config+=("--with-newlib")
    1.38              extra_config+=("--enable-threads=no")
    1.39              extra_config+=("--disable-shared")
    1.40 -            copy_headers=y
    1.41 +            copy_headers=y  # For baremetal, as there's no headers to copy,
    1.42 +                            # we copy an empty directory. So, who cares?
    1.43              ;;
    1.44          shared)
    1.45              core_prefix_dir="${CT_CC_CORE_SHARED_PREFIX_DIR}"
    1.46 @@ -257,6 +260,11 @@
    1.47      else # build_libgcc
    1.48          core_targets=( gcc )
    1.49      fi   # ! build libgcc
    1.50 +    if [    "${build_libstdcxx}" = "yes"    \
    1.51 +         -a "${CT_CC_LANG_CXX}"  = "y"      \
    1.52 +       ]; then
    1.53 +        core_targets+=( target-libstdc++-v3 )
    1.54 +    fi
    1.55  
    1.56      CT_DoLog EXTRA "Building ${mode} core C compiler"
    1.57      CT_DoExecLog ALL make ${PARALLELMFLAGS} "${core_targets[@]/#/all-}"