add README + fix compile script + add GCC's dependencies installation

This commit is contained in:
Yann MAGNIN 2021-11-17 19:41:16 +01:00
parent d4b8b52af7
commit 648fdbf86f
3 changed files with 102 additions and 6 deletions

89
README.md Normal file
View File

@ -0,0 +1,89 @@
# 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
SuperH architecture
(see on this subject from 2 years ago:
https://gcc.gnu.org/legacy-ml/gcc-help/current/000075.html).
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.
I am currently building a kernel of a Casio's calculator for a graduation
project and I need this functionality. I had discovered, thanks to Lephenixnoir,
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
dependent on a library called `libgcc`, which provide some useful critical
primitives and which is generated only statically (therefore with
non-relocatable code), which broke all shared object file generated with this
dependencie (and a lot of cases can involve this librarie).
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.
---
## Build
The build is relatively simple and can be done in two different ways: you can
use the `compile.sh` script which is at the root of the repository:
```bash
./compile /your/installation/path
```
Or you can use the `giteapc` tool, created by Lephenixnoir:
```bash
giteapc install sh-elf-vhex
```
It takes about twenty minutes for the build.
---
## Technical notes
The GCC build takes much longer than the `sh3eb-elf` target because we have two
stages for the GCC build. In order, we have:
* download + configuration of binutils sources
* download + configuration of GCC sources
* compilation of binutils
* compilation of GCC (stage-1) without enabling the shared library functionality
* compilation of OpenLibM (a dependency of our standard C library)
* compilation of fxlibc, our custom C standard library
* compilation of GCC (stage-2) with activation of the shared library fonctionality
* installation of our C library
* compilation of the shared libgcc
As for the details of the `sh-elf-vhex` target that we created:
* machine-specific features:
* (`t-slibgcc`) compilation of the shared libgcc
* (`t-libgcc-pic`) the compilation of the libgcc in PIC
* (`t-fdpbit`) compilation of the library for emulated floating point numbers
* global configuration:
* only C is supported
* only big endian encoding is supported
* we use the stdint header from `newlib`. Otherwise, the generation of `stdint.h` is incomplete
* we only target the SH4A-NOFPU processor (no backward compatibility with the SH3 assembler)
* each public symbol begins with an underscore
* by default, we link our own C library to each generation of an object file
* we do not provide a specialized default linker script (for the moment)
---
## Special thanks
A big thanks to Lephenixnoir who helped me a lot for the modification of the
sources and made this project possible!

View File

@ -1,9 +1,13 @@
#! /usr/bin/env bash
echo "Compil and install binutils"
cd scripts/binutils
./configure.sh --version=2.37 && ./build.sh && ./install.sh --prefix=/tmp
# check mandatory args
if [[ $# -eq 0 ]]; then
echo "missing install path prefix !" >&2
exit 1
fi
cd scripts/binutils
./configure.sh --version=2.37 && ./build.sh && ./install.sh --prefix="$1"
echo "Compil and install GCC"
cd ../gcc
./configure.sh --version=11.2.0 && ./build.sh && ./install.sh --prefix=/tmp
./configure.sh --version=11.2.0 && ./build.sh && ./install.sh --prefix="$1"

View File

@ -130,9 +130,12 @@ ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ld sh-elf-vhex/bin/ld
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ar sh-elf-vhex/bin/ar
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ranlib sh-elf-vhex/bin/ranlib
# patch OpenLibM building error (which search for sh-elf-vhex-ar)
# Patch OpenLibM building error (which search for sh-elf-vhex-ar)
ln -sf $(pwd)/../binutils/bin/sh-elf-vhex-ar sh-elf-vhex/bin/sh-elf-vhex-ar
# Install dependencies
./gcc/contrib/download_prerequisites
# Cache management
if [[ "$cache" == 'false' ]]; then