Custom GCC compiler for the Vhex project
Go to file
YannMagnin da8dfe3861
sh-elf-vhex - v2.0.0-dev12 : review all scripts
*fix*
> [project]
  | [readme] review content
> [scripts]
  | [all] review all strings and help message
2023-12-17 11:06:14 +01:00
patches sh-elf-vhex - v2.0.0-dev11 : bump support version to GCC 13.2.0 and binutils 2.41 2023-12-16 20:11:31 +01:00
scripts sh-elf-vhex - v2.0.0-dev12 : review all scripts 2023-12-17 11:06:14 +01:00
.gitignore sh-elf-vhex - v1.1.0 : Bump binutils and GCC version 2022-07-30 22:27:22 +02:00
README.md sh-elf-vhex - v2.0.0-dev12 : review all scripts 2023-12-17 11:06:14 +01:00

README.md

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:

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 for 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 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).

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.

Features/Limitations

  • 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 object files
  • we do not provide a specialized default linker script (for the moment)
  • compilation of the shared libgcc (t-slibgcc)
  • compilation of the libgcc in PIC (t-libgcc-pic)
  • compilation of the library for emulated floating point numbers (t-fdpbit)

Technical notes

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/

The project also automatically installs vxOpenLibm and vxLibc

Installing

The build is relatively simple and can be done in two different ways:

curl -s "https://github.com/YannMagnin/sh-elf-vhex/+/HEAD/scripts/bootstrap.sh?format=TEXT" | base64 --decode | bash

Or by cloning the project and using the bootstrap.sh script, see ./scripts/bootstrap.sh --help for more information about possible operations you can do with it (like uninstalling the compiler)

cd /tmp/
git clone 'https://github.com/YannMagnin/sh-elf-vhex.git' --depth=1
cd /tmp/sh-elf-vhex || exit 1
./script/bootstrap.sh

It takes about twenty minutes for the build.

Supported version list

Note that GCC 12.x will never be supported since many critical bugs have been found for the superh backend (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106609)

  • GCC 13.2.0 and binutils 2.41
  • GCC 11.2.0 and binutils 2.31

Special thanks

A big thanks to Lephenixnoir who helped me a lot for the modification of the sources and made this project possible!