newlib-nano: Build libstdc++ against newlib-nano if requested

This uses the gcc support for building libstdc++ using alternate lib
header files.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2021-01-11 23:27:45 -08:00
parent 15e053fdc4
commit beb587a271
2 changed files with 54 additions and 0 deletions

View File

@ -9,6 +9,15 @@
## help array of processors, and will usually work on any architecture with
## help the addition of a few low-level routines.
config NEWLIB_NANO_GCC_LIBSTDCXX
bool
prompt "Compile libstdc++ newlib-nano variant"
default y
depends on CC_LANG_CXX
help
This option compiles an additional target libstdc++ for use with
newlib-nano.
# maybe older versions of newlib will support it too, but this
# needs to be checked
config NEWLIB_NANO_CXA_ATEXIT

View File

@ -22,6 +22,49 @@ do_newlib_nano_extract() {
CT_ExtractPatch NEWLIB_NANO
}
#------------------------------------------------------------------------------
# Build an additional target libstdc++ with "-Os" (optimise for speed) option
# flag for libstdc++ "newlib_nano" variant.
do_cc_libstdcxx_newlib_nano()
{
local -a final_opts
local final_backend
if [ "${CT_NEWLIB_NANO_GCC_LIBSTDCXX}" = "y" ]; then
final_opts+=( "host=${CT_HOST}" )
final_opts+=( "libstdcxx_name=newlib-nano" )
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=c,c++" )
final_opts+=( "build_step=libstdcxx" )
if [ "${CT_LIBC_NEWLIB_NANO_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
final_opts+=( "enable_optspace=yes" )
fi
if [ "${CT_BARE_METAL}" = "y" ]; then
final_opts+=( "mode=baremetal" )
final_opts+=( "build_libgcc=yes" )
final_opts+=( "build_libstdcxx=yes" )
final_opts+=( "build_libgfortran=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 libstdc++ newlib-nano"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-libstdcxx-newlib-nano"
"${final_backend}" "${final_opts[@]}"
CT_Popd
CT_EndStep
fi
}
do_newlib_nano_for_target() {
local -a newlib_nano_opts
local cflags_for_target
@ -139,6 +182,8 @@ EOF
CT_Popd
CT_EndStep
do_cc_libstdcxx_newlib_nano
}
fi