From beb587a2711885e5630e695cf89767d5de5df4d1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 11 Jan 2021 23:27:45 -0800 Subject: 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 diff --git a/config/comp_libs/newlib-nano.in b/config/comp_libs/newlib-nano.in index ee05b92..0138a7f 100644 --- a/config/comp_libs/newlib-nano.in +++ b/config/comp_libs/newlib-nano.in @@ -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 diff --git a/scripts/build/companion_libs/350-newlib_nano.sh b/scripts/build/companion_libs/350-newlib_nano.sh index 498ef63..00ea948 100644 --- a/scripts/build/companion_libs/350-newlib_nano.sh +++ b/scripts/build/companion_libs/350-newlib_nano.sh @@ -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 -- cgit v0.10.2-6-g49f6