From fd04f436170a208ae30fe42ab2f56b543b0b81c5 Mon Sep 17 00:00:00 2001 From: Quentin Boswank Date: Sat, 12 Aug 2023 20:11:58 +0200 Subject: [PATCH] =?UTF-8?q?Add=20option=20to=20re-enable=20=CB=8Blibstdc++?= =?UTF-8?q?=CB=8B=20on=20avr=20targets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the small flash space on AVR devices the library containing the standard types in C++ (ˋlibstdc++ˋ) does not get built normally when enabling the C++ language support. This option is an easy way to go back to the PC-way where ˋlibstdc++ˋ is built. Signed-off-by: Quentin Boswank --- config/cc/gcc.in | 9 +++++ scripts/build/cc/gcc.sh | 2 + scripts/build/libc/avr-libc.sh | 68 +++++++++++++++++++++++++--------- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/config/cc/gcc.in b/config/cc/gcc.in index 1f50460a..d064ffb4 100644 --- a/config/cc/gcc.in +++ b/config/cc/gcc.in @@ -54,6 +54,15 @@ config CC_GCC_ENABLE_CXX_FLAGS Note: just pass in the option _value_, that is only the part that goes after the '=' sign. +config CC_GCC_EXTRA_LIBSTDCXX + bool "Re-enable libstdcxx" + default n + depends on LIBC_AVR_LIBC + select CC_CORE_PASS_2_NEEDED + help + libstdcxx is normally disabled on avr systems due to size limitations. + Set this option to re-enable libstdcxx support. + config CC_GCC_CORE_EXTRA_CONFIG_ARRAY string "Core gcc extra config" default "" diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index f14f31da..275e239c 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -1052,6 +1052,8 @@ do_gcc_backend() { if [ "${build_libstdcxx}" = "no" ]; then extra_config+=(--disable-libstdcxx) + elif [ "${CT_CC_GCC_EXTRA_LIBSTDCXX}" = "y" ]; then + extra_config+=(--enable-libstdcxx) fi if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh index 34eb0f55..c13ae39b 100644 --- a/scripts/build/libc/avr-libc.sh +++ b/scripts/build/libc/avr-libc.sh @@ -2,28 +2,60 @@ avr_libc_post_cc() { - CT_DoStep INFO "Installing C library" + if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then + CT_DoStep INFO "Installing C library" - CT_DoLog EXTRA "Copying sources to build directory" - CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc/." \ - "${CT_BUILD_DIR}/build-libc-post-cc" - cd "${CT_BUILD_DIR}/build-libc-post-cc" + CT_DoLog EXTRA "Copying sources to build directory" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc/." \ + "${CT_BUILD_DIR}/build-libc-post-cc" + cd "${CT_BUILD_DIR}/build-libc-post-cc" - CT_DoLog EXTRA "Configuring C library" + CT_DoLog EXTRA "Configuring C library" - CT_DoExecLog CFG \ - ${CONFIG_SHELL} \ - ./configure \ - --build=${CT_BUILD} \ - --host=${CT_TARGET} \ - --prefix=${CT_PREFIX_DIR} \ - "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}" + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + ./configure \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix=${CT_PREFIX_DIR} \ + "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}" - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make install + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make install - CT_EndStep + CT_EndStep + fi +} + +avr_libc_main() +{ + if [ "${CT_CC_CORE_PASS_2_NEEDED}" = "y" ]; then + CT_DoStep INFO "Installing C library" + + CT_DoLog EXTRA "Copying sources to build directory" + CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/avr-libc/." \ + "${CT_BUILD_DIR}/build-libc" + cd "${CT_BUILD_DIR}/build-libc" + + CT_DoLog EXTRA "Configuring C library" + + CT_DoExecLog CFG \ + ${CONFIG_SHELL} \ + ./configure \ + --build=${CT_BUILD} \ + --host=${CT_TARGET} \ + --prefix=${CT_PREFIX_DIR} \ + "${CT_LIBC_AVR_LIBC_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make install + + CT_EndStep + fi }