Cleanup old avr-libstdcxx code and make it usable on other targets
Some checks failed
CI / crosstool (macos-13) (push) Has been cancelled
CI / crosstool (ubuntu-22.04) (push) Has been cancelled
CI / tarballs (ubuntu-22.04) (push) Has been cancelled
CI / toolchains (push) Has been cancelled

Should not cause major unwanted behavior changes

 - C++ is now selected by default in many configs.

Signed-off-by: QBos07 <qubos@outlook.de>
[cp: depend on CC_LANG_CXX instead of select]
Signed-off-by: Chris Packham <judge.packham@gmail.com>
This commit is contained in:
QBos07 2024-12-01 15:41:48 +00:00 committed by Chris Packham
parent 71cfd2d094
commit 0145966e8e
3 changed files with 73 additions and 30 deletions

View File

@ -53,15 +53,6 @@ config CC_GCC_ENABLE_CXX_FLAGS
Note: just pass in the option _value_, that is only the part that goes Note: just pass in the option _value_, that is only the part that goes
after the '=' sign. 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 config CC_GCC_CORE_EXTRA_CONFIG_ARRAY
string "Core gcc extra config" string "Core gcc extra config"
default "" default ""
@ -240,6 +231,40 @@ config CC_GCC_ENABLE_TARGET_OPTSPACE
This will compile crossgcc's libs with -Os. This will compile crossgcc's libs with -Os.
config CC_GCC_LIBSTDCXX
tristate "Build libstdcxx"
default n if ARCH_AVR || LIBC_NONE
default m
depends on CC_LANG_CXX
select CC_CORE_NEEDED if ARCH_AVR
help
libstdcxx is normally disabled on some systems, like avr, due to size
limitations or it being not supported.
Set this option to force libstdcxx support.
Option | libstdcxx build | Associated ./configure switch
---------+--------------------+--------------------------------
Y | forcibly | --enable-libstdcxx
M | auto | (none, ./configure decides)
N | forcibly not | --disable-libstdcxx
config CC_GCC_LIBSTDCXX_HOSTED_DISABLE
bool "Build freestanding libstdcxx"
default y if LIBC_AVR_LIBC
default n
depends on CC_GCC_LIBSTDCXX
help
libstdcxx can be compiled in two modes: hosted and freestanding.
Hosted mode is the default, and is used when the OS is available.
Freestanding mode is used when the OS is not available, like in
bare-metal systems.
Some architectures, like avr, do not support hosted mode, but default
to it, and will fail to build libstdcxx in hosted mode.
Answer 'y' here to force freestanding mode, otherwise answer let
./configure decide.
config CC_GCC_LIBMUDFLAP config CC_GCC_LIBMUDFLAP
bool bool
prompt "Compile libmudflap" prompt "Compile libmudflap"

View File

@ -389,16 +389,32 @@ do_gcc_core_backend() {
"") extra_config+=("--disable-libstdcxx-verbose");; "") extra_config+=("--disable-libstdcxx-verbose");;
esac esac
if [ "${build_libstdcxx}" = "yes" ]; then
if [ "${CT_CC_GCC_LIBSTDCXX}" = "n" ]; then
build_libstdcxx="no"
elif [ "${CT_CC_GCC_LIBSTDCXX}" = "y" ]; then
extra_config+=("--enable-libstdcxx")
fi
if [ "${CT_LIBC_AVR_LIBC}" = "y" ]; then
extra_config+=("--enable-cstdio=stdio_pure")
fi
if [ "${CT_CC_GCC_LIBSTDCXX_HOSTED_DISABLE}" = "y" ]; then
extra_config+=("--disable-libstdcxx-hosted")
fi
fi
if [ "${build_libstdcxx}" = "no" ]; then if [ "${build_libstdcxx}" = "no" ]; then
extra_config+=(--disable-libstdcxx) extra_config+=(--disable-libstdcxx)
fi fi
if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then
extra_config+=("--with-default-libc=picolibc") extra_config+=("--with-default-libc=picolibc")
extra_config+=("--enable-stdio=pure") extra_config+=("--enable-stdio=pure")
if [ "${CT_PICOLIBC_older_than_1_8}" = "y" ]; then if [ "${CT_PICOLIBC_older_than_1_8}" = "y" ]; then
extra_config+=("--disable-wchar_t") extra_config+=("--disable-wchar_t")
fi fi
fi fi
core_LDFLAGS+=("${ldflags}") core_LDFLAGS+=("${ldflags}")
@ -697,9 +713,7 @@ do_gcc_core_backend() {
else # build_libgcc else # build_libgcc
core_targets=( gcc ) core_targets=( gcc )
fi # ! build libgcc fi # ! build libgcc
if [ "${build_libstdcxx}" = "yes" \ if [ "${build_libstdcxx}" = "yes" ]; then
-a "${CT_CC_LANG_CXX}" = "y" \
]; then
core_targets+=( target-libstdc++-v3 ) core_targets+=( target-libstdc++-v3 )
fi fi
@ -810,9 +824,7 @@ do_cc_for_build() {
# lack of such a compiler, but better safe than sorry... # lack of such a compiler, but better safe than sorry...
build_final_opts+=( "mode=baremetal" ) build_final_opts+=( "mode=baremetal" )
build_final_opts+=( "build_libgcc=yes" ) build_final_opts+=( "build_libgcc=yes" )
if [ "${CT_LIBC_NONE}" != "y" ]; then build_final_opts+=( "build_libstdcxx=yes" )
build_final_opts+=( "build_libstdcxx=yes" )
fi
build_final_opts+=( "build_libgfortran=yes" ) build_final_opts+=( "build_libgfortran=yes" )
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
build_final_opts+=( "build_staticlinked=yes" ) build_final_opts+=( "build_staticlinked=yes" )
@ -901,9 +913,7 @@ do_cc_for_host() {
if [ "${CT_BARE_METAL}" = "y" ]; then if [ "${CT_BARE_METAL}" = "y" ]; then
final_opts+=( "mode=baremetal" ) final_opts+=( "mode=baremetal" )
final_opts+=( "build_libgcc=yes" ) final_opts+=( "build_libgcc=yes" )
if [ "${CT_LIBC_NONE}" != "y" ]; then final_opts+=( "build_libstdcxx=yes" )
final_opts+=( "build_libstdcxx=yes" )
fi
final_opts+=( "build_libgfortran=yes" ) final_opts+=( "build_libgfortran=yes" )
if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
final_opts+=( "build_staticlinked=yes" ) final_opts+=( "build_staticlinked=yes" )
@ -1075,16 +1085,24 @@ do_gcc_backend() {
"") extra_config+=("--disable-libstdcxx-verbose");; "") extra_config+=("--disable-libstdcxx-verbose");;
esac esac
if [ "${build_libstdcxx}" = "no" ]; then if [ "${CT_CC_GCC_LIBSTDCXX}" = "n" ]; then
extra_config+=(--disable-libstdcxx) extra_config+=(--disable-libstdcxx)
elif [ "${CT_CC_GCC_EXTRA_LIBSTDCXX}" = "y" ]; then elif [ "${CT_CC_GCC_LIBSTDCXX}" = "y" ]; then
extra_config+=(--enable-libstdcxx) extra_config+=(--enable-libstdcxx)
fi fi
if [ "${CT_CC_GCC_LIBSTDCXX_HOSTED_DISABLE}" = "y" ]; then
extra_config+=("--disable-libstdcxx-hosted")
fi
if [ "${CT_LIBC_AVR_LIBC}" = "y" ]; then
extra_config+=("--enable-cstdio=stdio_pure")
fi
if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then
extra_config+=("--with-default-libc=picolibc") extra_config+=("--with-default-libc=picolibc")
extra_config+=("--enable-stdio=pure") extra_config+=("--enable-stdio=pure")
extra_config+=("--disable-wchar_t") extra_config+=("--disable-wchar_t")
fi fi
final_LDFLAGS+=("${ldflags}") final_LDFLAGS+=("${ldflags}")

View File

@ -2,7 +2,7 @@
avr_libc_post_cc() avr_libc_post_cc()
{ {
if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then if [ "${CT_CC_CORE_NEEDED}" != "y" ]; then
CT_DoStep INFO "Installing C library" CT_DoStep INFO "Installing C library"
CT_DoLog EXTRA "Copying sources to build directory" CT_DoLog EXTRA "Copying sources to build directory"
@ -32,7 +32,7 @@ avr_libc_post_cc()
avr_libc_main() avr_libc_main()
{ {
if [ "${CT_CC_CORE_PASS_2_NEEDED}" = "y" ]; then if [ "${CT_CC_CORE_NEEDED}" = "y" ]; then
CT_DoStep INFO "Installing C library" CT_DoStep INFO "Installing C library"
CT_DoLog EXTRA "Copying sources to build directory" CT_DoLog EXTRA "Copying sources to build directory"