Meta-repository providing a build of gcc, g++ and libstdc++ for SuperH.
Find a file
2021-06-13 16:34:11 +02:00
.gitignore add a :noclean configuration to leave the build folder 2021-05-04 20:05:58 +02:00
build.sh build: use gmake on OpenBSD 2021-03-18 14:25:27 +01:00
configure.sh remove build folder when deciding to skip build, take 2 2021-03-23 15:33:07 +01:00
giteapc-config-any.make add an any configuration that uses existing GCC installs 2021-01-14 19:14:12 +01:00
giteapc-config-noclean.make add a :noclean configuration to leave the build folder 2021-05-04 20:05:58 +02:00
giteapc.make bump to 11.1.0 2021-05-04 20:06:33 +02:00
install.sh add a :noclean configuration to leave the build folder 2021-05-04 20:05:58 +02:00
README.md add notes on attempts at building libstdc++-v3 2021-06-13 16:34:11 +02:00
uninstall.sh split off binutils into a separate repository 2021-01-02 00:13:11 +01:00
util.sh explicitly link previously-built binutils to GCC 2021-01-02 22:48:31 +01:00

Automatic sh-elf-gcc installer

This script can be used to automatically compile and install a GCC cross-compiler targeting SH3 and SH4 calculators. The normal use is with GiteaPC:

% giteapc install Lephenixnoir/sh-elf-gcc

You can also install manually. First install sh-elf-binutils, then run the GiteaPC Makefile with a manually-specified install prefix:

% make -f giteapc.make configure build install PREFIX=$HOME/.local

An any configuration is provided in case GCC is already installed externally, to have this package installed without rebuilding it.

% giteapc install Lephenixnoir/sh-elf-gcc:any

Notes on building libstdc++-v3

These are experimental notes on attempts at building the free-standing subset of the C++ standard library implementation bundled with GCC, libstdc++-v3. For the official manual, see libstdc++ info manual, Chapter 2: Setup (gcc.gnu.org).

This is the free-standing subset which has basically nothing in it, see Freestanding and hosted implementations (cppreference.com). As a rule of thumb only features that look like extensions of the language are supported in there (RTTI, exceptions, coroutines, etc.) and everything that looks like a library (STL containers, I/O tools, filesystem) you can forget about.

So how do we go around doing that?

First configure GCC as usual (follow configure.sh), but use a separate build folder. Since this is experimental the files are likely to stay here longer while debugging and you don't want them gone during a GCC upgrade. There are a couple of additional flags to care about, mainly described here.

% export PREFIX="$(pwd)"
% mkdir build-libstdc++
% cd build-libstdc++
% ../gcc-11.1.0/configure --prefix="$PREFIX" --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --enable-languages=c,c++ --without-headers --with-newlib --program-prefix=sh-elf- --enable-libssp --enable-lto --enable-clocale=generic --enable-libstdcxx-allocator --disable-threads --disable-hosted-libstdcxx --disable-libstdcxx-verbose
  • --enable-clocale=generic: We want minimal locales and this is certainly the minimalistic option.
  • --enable-libstdcxx-allocator: =malloc might be an option too.
  • --disable-threads: Obvious.
  • --disable-hosted-libstdcxx: This builds only the free-standing subset of the library (one thing at a time).
  • --disable-libstdcxx-verbose: We don't have a systematic standard error stream anyway.

Now build and install that GCC and the libgcc.

% make -j$(nproc) all-gcc all-target-libgcc
% make -j$(nproc) install-strip-gcc install-strip-target-libgcc

Then go an install fxlibc since we're certainly not going to build the C++ standard library without the C standard library.

After this, come back to the build folder, run the build command for libstdc++-v3, and hope it works out. I recommend not using -j as it makes error messages and logs more linear.

% make all-target-libstdc++-v3

Since this will likely fail, check out sh3eb-elf/libstdc++-v3/config.log for configure errors, or other log files if you make it past the configuration step. config.log has many details on programs that failed to compile; not all failures to build are fatal for the configuration step, but some are.

Current problems

  • The programs are built without -ffreestanding, which means anything autoconf tries to link is provided with GCC's C runtime in the form of crt1.o and other files we really don't want. There are some link errors due to missing symbols. The expected solution is to build everything with -ffreestanding (since it doesn't disable the libc, only __STDC_HOSTED__ and this type of link mechanisms).