mirror of
https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc.git
synced 2024-12-28 04:23:39 +01:00
add notes on attempts at building libstdc++-v3
This commit is contained in:
parent
1d344aa076
commit
55017f002f
1 changed files with 44 additions and 0 deletions
44
README.md
44
README.md
|
@ -17,3 +17,47 @@ An `any` configuration is provided in case GCC is already installed externally,
|
|||
```
|
||||
% 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](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).
|
||||
|
||||
```
|
||||
% 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](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.
|
||||
|
||||
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).
|
||||
|
|
Loading…
Reference in a new issue