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`](https://gitea.planet-casio.com/Lephenixnoir/sh-elf-binutils), then run the GiteaPC Makefile with a manually-specified install prefix:
```
% make -f giteapc.make configure build install PREFIX=$HOME/.local
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](https://gcc.gnu.org/onlinedocs/libstdc++/manual/setup.html) (gcc.gnu.org).
This is the **free-standing subset** which has basically nothing in it, see [Freestanding and hosted implementations](https://en.cppreference.com/w/cpp/freestanding) (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](https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html).
*`--enable-cxx-flags="-ffreestanding"`: Really everything should be free-standing here. It doesn't apply to conftest programs apparently, which (fail to) link with the default C runtime (`crt1.o` etc), maybe something will need to be done about that in the future.
Next step is to install [OpenLibm](https://gitea.planet-casio.com/Lephenixnoir/OpenLibm) and [fxlibc](https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/) since we're certainly not going to build the C++ standard library without the C standard library.
For some reason OpenLibm installs its headers in the `include/openlibm` subfolder, but then includes them as if they were in `include`, so we have to add a path. Normally either the projet provides that path, or gint does it through its CMake find module. Here we can symlink to the `sh3eb-elf/sys-include` folder in this repo's root folder (or `include` but it's already symlinked to the compiler's install folder and we don't really want to override that).
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.
* The conftest programs are built without `-ffreestanding`, which means autoconf cannot really link stuff. This is probably not too much of a problem, because it's cross-compiled anyway so there's nothing to do with a linked program, but who knows.
* autoconf compiles conftest programs as if on a fully-featured dynamic OS, which is nowhere near true (eg. it builds with `-shared-libgcc`).