Feature request: Add a nano build

Description:

When doing embedded C++ work, a full size stdc++ with exception support is huge. To combat this, the Arch Linux arm-none-eabi-gcc package has a *-nano build. This creates the same libstdc++ and libsupc++ libraries as the normal build, but without exception support. These are then moved into the normal build as libstdc++_nano and libsupc++_nano, which can then be used when doing embedded C++ development to save quite some space (easily 100 kB).

Additional info:

Because I was unaware this package existed, I created a PKGBUILD with a set of nano libs. It is derived from the arm-none-eabi-gcc PKGBUILD, and contains more changes than just this. Maybe it is helpful:

# Maintainer: Jacko Dirks <jacko dot dirks at gmail dot com>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Martin Schmölzer <mschmoelzer@gmail.com>

_target=riscv-none-elf
pkgname=$_target-gcc
pkgver=14.1.0
pkgrel=3
pkgdesc='The GNU Compiler Collection - cross compiler for RISC-V (bare-metal) target'
arch=(x86_64)
url='https://gcc.gnu.org/'
license=(GPL LGPL FDL)
depends=($_target-binutils zlib libmpc libisl zstd)
makedepends=(gmp mpfr "$_target-newlib")
optdepends=("$_target-newlib: Standard C library optimized for embedded systems")
options=(!emptydirs !lto !strip)
conflicts=("${_target}-gcc-stage1")
replaces=("${_target}-gcc-stage1")
source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz)
sha512sums=('e9e224f2b26646fcf038d28dfa08b94c623bc57941f99894a321d01c600f7c68aff6b8837fd25e73e540de1f8de5606e98694a62cdcdfb525ce768b3ef6879ea')
validpgpkeys=(33C235A34C46AA3FFB293709A328C3A2C3C45C06  # Jakub Jelinek <jakub@redhat.com>
              D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62  # Jakub Jelinek <jakub@redhat.com>
              13975A70E63C361C73AE69EF6EEB81F8981C74C7) # Richard Guenther <richard.guenther@gmail.com>
_basedir=gcc-$pkgver

prepare() {
  cd $_basedir

  echo $pkgver > gcc/BASE-VER

  mkdir "$srcdir"/build-gcc
  mkdir "$srcdir"/build-gcc-nano
}

_build_gcc() {
  "$srcdir"/$_basedir/configure \
    --target=$_target \
    --prefix=/usr \
    --with-sysroot=/usr/$_target \
    --with-native-system-header-dir=/include \
    --libexecdir=/usr/lib \
    --enable-languages=c,c++ \
    --enable-plugins \
    --disable-decimal-float \
    --disable-libffi \
    --disable-libgomp \
    --disable-libmudflap \
    --disable-libquadmath \
    --disable-libssp \
    --disable-libstdcxx-pch \
    --disable-nls \
    --disable-shared \
    --disable-threads \
    --disable-tls \
    --with-gnu-as \
    --with-gnu-ld \
    --with-system-zlib \
    --with-newlib \
    --with-headers=/usr/$_target/include \
    --with-python-dir=share/gcc-$_target \
    --with-gmp \
    --with-mpfr \
    --with-mpc \
    --with-isl \
    --with-libelf \
    --enable-gnu-indirect-function \
    --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'

  make
}

build() {
  # Credits @allanmcrae
  # https://github.com/allanmcrae/toolchain/blob/f18604d70c5933c31b51a320978711e4e6791cf1/gcc/PKGBUILD
  # TODO: properly deal with the build issues resulting from this
  CFLAGS=${CFLAGS/-Werror=format-security/}
  CXXFLAGS=${CXXFLAGS/-Werror=format-security/}

  cd "$srcdir"/build-gcc
  export CFLAGS_FOR_TARGET="-g -Os -pipe"
  export CXXFLAGS_FOR_TARGET="-g -Os -pipe"
  _build_gcc

  cd "$srcdir"/build-gcc-nano
  export CFLAGS_FOR_TARGET="-g -Oz -pipe"
  export CXXFLAGS_FOR_TARGET="-g -Oz -pipe -fno-exceptions"
  _build_gcc
}

package() {
  cd "$srcdir"/build-gcc
  make DESTDIR="$pkgdir" install -j1

  cd "$srcdir"/build-gcc-nano
  make DESTDIR="$pkgdir.nano" install -j1
  # we need only libstdc nano files
  multilibs=( $("$pkgdir"/usr/bin/$_target-gcc -print-multi-lib 2>/dev/null) )
  for multilib in "${multilibs[@]}"; do
    dir="${multilib%%;*}"
    from_dir="$pkgdir".nano/usr/$_target/lib/"$dir"
    to_dir="$pkgdir"/usr/$_target/lib/"$dir"
    cp -f "$from_dir"/libstdc++.a "$to_dir"/libstdc++_nano.a
    cp -f "$from_dir"/libsupc++.a "$to_dir"/libsupc++_nano.a
  done

  # strip host binaries
  find "$pkgdir"/usr/bin/ -type f -executable -exec strip '{}' \;

  # Remove files that conflict with host gcc package
  rm -r "$pkgdir"/usr/share/man/man7
  rm -r "$pkgdir"/usr/share/info
  rm "$pkgdir"/usr/lib/libcc1.*
}