Works with GCC 12, older versions have bugs in the configure script which prevent building libstdc++ directly. It might be possible to work around that by building GCC and then cross-compiling libstdc++ separately...?
export TARGET=mipsel-elf
export PREFIX=/opt/rbdev-gcc12-cxx
export CFLAGS='-U_FORTIFY_SOURCE -fgnu89-inline -O2'
export CXXFLAGS='-std=gnu++11'
../binutils-2.39/configure --prefix=$PREFIX --target=$TARGET \
--disable-docs --disable-werror
make -j8
make install
TODO: Some of these options could be redundant...
../gcc-12.2.0/configure --target=$TARGET --prefix=$PREFIX \
--disable-docs --enable-languages=c,c++ --disable-werror \
--disable-threads --disable-shared --disable-libssp \
--disable-dlopen --disable-libgomp --disable-libstdcxx-pch \
--without-headers --with-newlib --disable-nls --disable-bootstrap \
--disable-hosted-libstdcxx
make -j8
make install
At the end, the resulting toolchain only has a minimal set of C++ headers:
atomic
bit
cfloat
ciso646
climits
compare
concepts
coroutine
cstdalign
cstdarg
cstdbool
cstddef
cstdint
cstdlib
cxxabi.h
exception
initializer_list
limits
new
source_location
type_traits
typeinfo
version