clean up toolchain documentation

This commit is contained in:
AdaOrbit 2026-04-17 19:34:58 +02:00
parent cad5c37dab
commit 738ba7e0c8
2 changed files with 58 additions and 30 deletions

View file

@ -7,8 +7,8 @@ Building and developing Ada applications for the **Casio fx-CG50**
The Casio fx-CG50 (from here on only called CG50) uses the SuperH architecture. Specifically a custom SH4-A chip. To be able to develope Add-ons, we first need to compile gcc with Ada and SuperH support. The Casio fx-CG50 (from here on only called CG50) uses the SuperH architecture. Specifically a custom SH4-A chip. To be able to develope Add-ons, we first need to compile gcc with Ada and SuperH support.
> [!NOTE] > [!NOTE]
> This guide is mostly based on [Lephenixnoir](https://git.planet-casio.com/Lephenixnoir) guides for building fxSDK manually. > You need a working ada compiler to compile ada. If you don't have gnat available in your repo, you can compile a stage1 gcc compiler.
> I have changed a few parts to add Ada support _without_ an Ada Runtime (Later project) > For my own sanity sake, I'll just assume that you already have gnat installed on your system.
## Building a GNAT cross compiler ## Building a GNAT cross compiler
@ -21,17 +21,13 @@ tar -xf binutils.tar.gz
tar -xf gcc.tar.gz tar -xf gcc.tar.gz
``` ```
> [!NOTE]
> You need a working ada compiler to compile ada. If you don't have gnat available in your repo, you can compile a stage1 gcc compiler.
> For my own sanity sake, I'll just assume that you already have gnat installed on your system.
Prepare the build environment to configure the tools. Prepare the build environment to configure the tools.
```bash ```bash
mkdir build-binutils build-gcc sysroot mkdir build-binutils build-gcc sysroot
``` ```
`sysroot` is where _gcc_ and _binutils_ is going to be installed at. The `build-*` directories is where the tools are going to be build at. But before we do that we first have to configure them. `sysroot` is where _gcc_ and _binutils_ is going to be installed at. The `build-*` directories are where the tools are going to be build at. But before we do that we first have to configure them.
### Configuring binutils ### Configuring binutils
@ -52,12 +48,12 @@ You might ask yourself now why we chose these flags. Here I have tried to lay ou
|----------------------- | ----------------------------------------------------- | |----------------------- | ----------------------------------------------------- |
| --prefix | The install path. In our case it's `sysroot` | | --prefix | The install path. In our case it's `sysroot` |
| --target | What our target architecture is. The CG50 uses SuperH | | --target | What our target architecture is. The CG50 uses SuperH |
| --with-multilib-list | TODO: for what is that? | | --with-multilib-list | which CPUs we target. |
| --program-prefix | prefix of the binuitls tools | | --program-prefix | prefix of the binuitls tools |
| --enable-libssp | No Idea | | --enable-libssp | No Idea |
| --enable-lto | Link Time Optimization. Glue code faster together | | --enable-lto | Link Time Optimization. Glue code faster together |
### Compiling binutils #### Compiling binutils
We now compile `binutils` with our custom configuration using We now compile `binutils` with our custom configuration using
@ -66,9 +62,9 @@ make -j$(nproc)
make install-strip make install-strip
``` ```
We now configure and install `gcc` using the same steps but with different flags. We will now configure and install `gcc` using the same steps but with different flags.
### Configuring GCC (Part 1) ### Configuring GCC
We will first compile a working C cross compiler without a libc and add it later on to compile gcc with C++ and Ada support. We will first compile a working C cross compiler without a libc and add it later on to compile gcc with C++ and Ada support.
@ -91,16 +87,17 @@ cd ../build-gcc
--enable-cxx-flags="-fno-exceptions" --enable-cxx-flags="-fno-exceptions"
``` ```
TODO: Da fuck all these flags for? The most important flags are described here.
| Column1 | Column2 | | Flags | Effect |
|--------------- | --------------- | |------------------------- | --------------------------------------------------------------- |
| --disable-libada | We will be adding our own runtime | | --target="sh3eb-elf" | Compile Code to sh3 |
| Item1.2 | Item2.2 | | --enable-languages="ada" | Add support for the Ada language |
| Item1.3 | Item2.3 | | --without-libada | We will be adding our own runtime as there is none for casiowin |
| Item1.4 | Item2.4 |
Many of the other flags are for enabling C++ support, however, with gcc15 I wasn't able to add C++ support and with gcc14 there where too many nuances to get Ada to work. For now these extra flags stay here for future use.
### Compiling GCC #### Compiling GCC (Step 1)
We now compile `gcc` the same way we did `binutils`. We now compile `gcc` the same way we did `binutils`.
@ -122,7 +119,7 @@ The `PREFIX` directory is where gcc is going to look for all the system headers.
### Adding libc ### Adding libc
We will now install a libc implementation that works on the CG50. For that we will use [OpenLibm](https://git.planet-casio.com/Lephenixnoir/OpenLibm) and [libfxcg](https://github.com/Jonimoose/libfxcg.git) We will now install a libc implementation that works on the CG50. For that we will use [libfxcg](https://github.com/Jonimoose/libfxcg.git)
```bash ```bash
git clone https://github.com/Jonimoose/libfxcg.git git clone https://github.com/Jonimoose/libfxcg.git
@ -135,6 +132,14 @@ cp lib/* ../sysroot/lib/
cp -r include/* ../sysroot/lib/gcc/sh3eb-elf/15.2.0/include/ cp -r include/* ../sysroot/lib/gcc/sh3eb-elf/15.2.0/include/
``` ```
> [!NOTE]
> There is also the libc from gint and vhex but those target also other calculators that I don't have access to.
> For my own sanity sake I'll just stick with libfxcg
### Installing gnattools
We do not necsairaly need to build gnattools in order to compile ada, but it was helpfull during development to debug and figure out how to integrate our custom gcc compiler to gprbuild.
Go back to build-gcc and run Go back to build-gcc and run
```bash ```bash
@ -142,14 +147,12 @@ make -C gcc cross-gnattools
make install-strip make install-strip
``` ```
> [!NOTE] gnat is now installed in our sysroot!
> There is also gint and vhex form the repo but those target also other calculators that I don't have access to.
> For my own sanity sake I'll just stick with the casiowin-cg
## Compiling GCC (Part 2) #### Compiling GCC (Part 2)
> [!WARNING] > [!WARNING]
> Building gcc with c++ does not work > Building gcc with c++ does not work!!! These instrucitons are here for future use!!!
Build now the c++ support with Build now the c++ support with
@ -162,7 +165,7 @@ make install-strip-target-libstdc++-v3
## packaging the binary ## packaging the binary
We will need to build `mkg3a` to package the binary. We will need to build `mkg3a`, a tool to package binaries to a format that CasioWin can use.
```bash ```bash
git clone https://gitlab.com/taricorp/mkg3a.git git clone https://gitlab.com/taricorp/mkg3a.git
@ -173,10 +176,33 @@ make
make install/local # do not want to install it to the system but to make install/local # do not want to install it to the system but to
``` ```
## Adding our custom compiler to GPRBuild The tools are now in the current diredtory, however they are not in our `PATH` yet. Add them by either adding
TODO: look into ironclad gprbuild integration ### Adding our custom compiler to GPRBuild
We need to tell the build system (in our case GPRbuild) that it has to use our custom gcc. We do this in the following way.
``` ada
package Compiler is
for Driver ("Ada") use "/path/to/gcc";
end Compiler;
```
We also have to tell the linker to use our custom linker.
``` ada
package Linker is
for Driver use "/path/to/gcc";
end Linker;
```
---
You now have access to an ada cross compiler for the sh3 achitecture!
The next steps are now to build your first application!!!
Good luck and happy hacking!
Sources used: Sources used:
- https://osdev.wiki/wiki/GNAT_Cross-Compiler - https://osdev.wiki/wiki/GNAT_Cross-Compiler
@ -184,6 +210,7 @@ Sources used:
- https://gcc.gnu.org/install/configure.html - https://gcc.gnu.org/install/configure.html
- https://git.planet-casio.com/Lephenixnoir/fxsdk - https://git.planet-casio.com/Lephenixnoir/fxsdk
- https://prizm.cemetech.net/Mkg3a/ - https://prizm.cemetech.net/Mkg3a/
- https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/companion_tools.html#general-compilation-attributes-l1460
--- ---
Copyright (c) 2026 Ada Orbit. All Rights Reserved. Copyright (c) 2026 Ada Orbit. All Rights Reserved.

View file

@ -21,13 +21,14 @@ ADACASIO_TARGET="sh3eb-elf"
#dnf install @c-development gnat gprbuild gmp-devel mpfr-devel libmpc-devel git #dnf install @c-development gnat gprbuild gmp-devel mpfr-devel libmpc-devel git
# prepare configure and build enviornment # prepare configure and build enviornment
#wget -O binutils.tar.gz $ADACASIO_BINUTILS_URL wget -O binutils.tar.gz $ADACASIO_BINUTILS_URL
#wget -O gcc.tar.gz $ADACASIO_GCC_URL wget -O gcc.tar.gz $ADACASIO_GCC_URL
tar -xf binutils.tar.gz tar -xf binutils.tar.gz
tar -xf gcc.tar.gz tar -xf gcc.tar.gz
# Got the command list from https://git.planet-casio.com/Lephenixnoir/sh-elf-binutils Method 3 # Got the command list from https://git.planet-casio.com/Lephenixnoir/sh-elf-binutils Method 3
# Step 2. configure and build GCC and binutils # Step 2. configure and build GCC and binutils
mkdir build-binutils build-gcc $ADACASIO_PREFIX mkdir build-binutils build-gcc $ADACASIO_PREFIX
cd build-binutils cd build-binutils