libstdc++-v3: some progress

This commit is contained in:
Lephenixnoir 2021-06-13 17:12:45 +02:00
parent 55017f002f
commit 9f33074c10
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 21 additions and 3 deletions

View File

@ -32,7 +32,7 @@ First configure GCC as usual (follow `configure.sh`), but use a separate build f
% 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
% ../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-cxx-flags="-ffreestanding"
```
* `--enable-clocale=generic`: We want minimal locales and this is certainly the minimalistic option.
@ -40,6 +40,7 @@ First configure GCC as usual (follow `configure.sh`), but use a separate build f
* `--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.
* `--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.
Now build and install that GCC and the libgcc.
@ -48,7 +49,16 @@ Now build and install that GCC and the libgcc.
% make -j$(nproc) install-strip-gcc install-strip-target-libgcc
```
Then go an install [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.
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).
```
% SRC="$(sh-elf-gcc -print-file-name=include/openlibm)"
% DST="../sh3eb-elf/sys-include"
% mkdir -p "$DST"
% for x in "$SRC"/*.h; do ln -s "$x" "$DST/${x#$SRC/}"; done
```
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.
@ -60,4 +70,12 @@ Since this will likely fail, check out `sh3eb-elf/libstdc++-v3/config.log` for c
### 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).
Hard limits:
* `<stdio.h>` is not complete yet.
Suspected problems:
* 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`).