2021-11-17 19:41:16 +01:00
|
|
|
# sh-elf-vhex - modified GCC for the Vhex kernel projet
|
|
|
|
|
|
|
|
## Context
|
|
|
|
|
|
|
|
This project was born following the discovery of a limitation with GCC on the
|
2023-12-16 18:25:13 +01:00
|
|
|
SuperH architecture
|
|
|
|
[see on this subject from 2 years ago](
|
|
|
|
https://gcc.gnu.org/legacy-ml/gcc-help/current/000075.html
|
|
|
|
):
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
The generation of dynamic libraries is blocked by GCC (the `--shared` flag is
|
|
|
|
ignored), because the `sh3eb-elf` target (the one used for cross-compiling on
|
|
|
|
Casio calculators), does not support this functionality.
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
I am currently building a kernel for Casio's calculator for a graduation
|
|
|
|
project and I need this functionality. I had discovered, thanks to
|
|
|
|
[Lephenixnoir](https://silent-tower.net/research/),
|
2021-11-17 19:41:16 +01:00
|
|
|
that we could generate 'shared' libraries by using directly `ld` with a custom
|
|
|
|
linker script, but this workaround was of short duration. Indeed, we are
|
2023-12-17 11:06:14 +01:00
|
|
|
dependent on a library called `libgcc`, which provides some useful critical
|
|
|
|
primitives and is generated only in static (therefore with
|
|
|
|
non-relocatable code) which breaks all shared object files generated with this
|
|
|
|
dependency (and a lot of cases can involve this library).
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
With the help of Lephenixnoir, we tried to add a target for the
|
|
|
|
superH architecture called `sh-elf-vhex`, allowing us to enable these features
|
|
|
|
and that's what we finally came up with.
|
|
|
|
|
|
|
|
This repository gathers only the files that we had to modify for
|
|
|
|
`binutils` and` GCC`, as well as scripts to automate the installation of this
|
|
|
|
particular GCC.
|
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
## Features/Limitations
|
|
|
|
|
|
|
|
* only C is supported
|
|
|
|
* only big endian encoding is supported
|
2023-12-17 11:06:14 +01:00
|
|
|
* we use the `stdint` header from `newlib`. Otherwise, the generation of `stdint.h` is incomplete
|
2023-12-16 18:52:43 +01:00
|
|
|
* we only target the `SH4A-NOFPU` processor (no backward compatibility with the SH3 assembler)
|
|
|
|
* each public symbol begins with an underscore
|
2023-12-17 11:06:14 +01:00
|
|
|
* by default, we link our own C library to each generation of object files
|
2023-12-16 18:52:43 +01:00
|
|
|
* we do not provide a specialized default linker script (for the moment)
|
|
|
|
* compilation of the shared libgcc (`t-slibgcc`)
|
2023-12-17 11:06:14 +01:00
|
|
|
* compilation of the libgcc in PIC (`t-libgcc-pic`)
|
2023-12-16 18:52:43 +01:00
|
|
|
* compilation of the library for emulated floating point numbers (`t-fdpbit`)
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Technical notes
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-16 18:52:43 +01:00
|
|
|
The bootstrap process will clone this repository at
|
|
|
|
`~/.local/share/sh-elf-vhex` then will start the installation using:
|
|
|
|
|
|
|
|
* `prefix-clone` = `~/.local/share/sh-elf-vhex`
|
|
|
|
* `prefix-sysroot` = `~/.local/share/sh-elf-vhex/_sysroot`
|
|
|
|
* `prefix-install` = `~/.local/bin/`
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
The project also automatically installs
|
2023-12-16 18:52:43 +01:00
|
|
|
[vxOpenLibm](https://github.com/YannMagnin/vxOpenLibm)
|
|
|
|
and [vxLibc](https://github.com/YannMagnin/vxLibc)
|
2023-12-16 18:25:13 +01:00
|
|
|
|
|
|
|
## Installing
|
|
|
|
|
|
|
|
The build is relatively simple and can be done in two different ways:
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 17:14:44 +01:00
|
|
|
Using `curl` and `jq`:
|
2021-11-17 19:41:16 +01:00
|
|
|
```bash
|
2023-12-19 17:54:01 +01:00
|
|
|
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/bootstrap.sh | bash
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
Or by cloning the project and using the `bootstrap.sh` script, see
|
2023-12-17 11:06:14 +01:00
|
|
|
`./scripts/bootstrap.sh --help` for more information about possible operations
|
2023-12-16 18:25:13 +01:00
|
|
|
you can do with it (like uninstalling the compiler)
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
```bash
|
2023-12-16 18:25:13 +01:00
|
|
|
cd /tmp/
|
|
|
|
git clone 'https://github.com/YannMagnin/sh-elf-vhex.git' --depth=1
|
|
|
|
cd /tmp/sh-elf-vhex || exit 1
|
|
|
|
./script/bootstrap.sh
|
2021-11-17 19:41:16 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
It takes about twenty minutes for the build.
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
## Supported version list
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
Note that GCC `12.x` will never be supported since many critical bugs have been
|
2023-12-16 18:25:13 +01:00
|
|
|
found for the superh backend
|
|
|
|
(https://gcc.gnu.org/bugzilla/show\_bug.cgi?id=106609)
|
2021-11-17 19:41:16 +01:00
|
|
|
|
2023-12-17 11:06:14 +01:00
|
|
|
- GCC `13.2.0` and binutils `2.41`
|
2023-12-16 18:25:13 +01:00
|
|
|
- GCC `11.2.0` and binutils `2.31`
|
2021-11-17 19:41:16 +01:00
|
|
|
|
|
|
|
## Special thanks
|
|
|
|
|
2023-12-16 18:25:13 +01:00
|
|
|
A big thanks to [Lephenixnoir](https://silent-tower.net/research/) who helped
|
|
|
|
me a lot for the modification of the sources and made this project possible!
|