.gitignore | ||
build.sh | ||
configure.sh | ||
giteapc-config-any.make | ||
giteapc-config-noclean.make | ||
giteapc.make | ||
install.sh | ||
README.md | ||
uninstall.sh | ||
util.sh |
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 ofcrt1.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).