sh-elf-binutils/README.md

68 lines
3.5 KiB
Markdown
Raw Permalink Normal View History

# SuperH toolchain: `sh-elf-binutils`
2021-01-02 10:38:07 +01:00
This repository provides a guide and automated scripts to install an SH3/SH4-compatible [binutils](https://www.gnu.org/software/binutils/) suite. binutils is a collection of tools to assemble, edit and link binary programs, mainly object files. It is the main dependency for GCC, which compiles C down to assembler and relies on binutils to assemble and link this assembler output.
2021-01-02 10:38:07 +01:00
The following three methods all install binutils with different degrees of automation.
## Method 1: Using GiteaPC
The most common way to install binutils (for the fxSDK) is by using [GiteaPC](https://gitea.planet-casio.com/Lephenixnoir/GiteaPC):
```bash
2021-01-02 10:38:07 +01:00
% giteapc install Lephenixnoir/sh-elf-binutils
```
This will take care of all the steps and install binutils in the fxSDK's SuperH system root.
A `:any` configuration is provided in case you already have another version of binutils installed in the fxSDK sysroot and want to keep using it (ie. skip a version upgrade). This will mark this repository as installed, so other repositories depending on it can build, without actually compiling binutils. Having binutils installed outside the fxSDK sysroot is not sufficient for some libraries.
2021-01-02 10:38:07 +01:00
```bash
% giteapc install Lephenixnoir/sh-elf-binutils:any
2021-01-02 10:38:07 +01:00
```
A `:clean` configuration is also provided if you want to clean up the source and build files automatically after installing. This frees up some disk space.
```bash
% giteapc install Lephenixnoir/sh-elf-binutils:clean
2021-01-02 10:38:07 +01:00
```
## Method 2: Manually running the scripts
You can also install binutils by directly running this repository's scripts. In terms of dependencies, you will need:
* [fxSDK](https://gitea.planet-casio.com/Lephenixnoir/fxsdk) ≥ 2.9 (provides the sysroot)
* Most of the [requirements for GCC](https://gcc.gnu.org/install/prerequisites.html) are checked by `configure.sh`
2022-08-19 15:07:23 +02:00
You can run `fxsdk path sysroot` to show the SuperH sysroot where binutils will be installed. You will need to specify a PATH-reachable `PREFIX` where the binaries of the toolchain will be symlinked. (The `PREFIX` is *only* for symlinks to executables, the toolchain will always be installed in the fxSDK's sysroot.) Once you're ready, run the main scripts with `make`:
```bash
% make -f giteapc.make configure build install PREFIX="$HOME/.local"
```
## Method 3: Fully manually
2022-08-19 15:07:23 +02:00
Get your version of choice from [ftp.gnu.org](https://ftp.gnu.org/gnu/binutils/) and extract the archive. Touch `binutils-$VERSION/intl/plural.c` to avoid autotools rebuilding it with bison, which no longer works ([[1]](https://sourceware.org/bugzilla/show_bug.cgi?id=22941),[[2]](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92008)).
2022-08-19 15:07:23 +02:00
If you want to use the fxSDK, you must install in the SDK's SuperH sysroot and set the `PREFIX` to `$(fxsdk path sysroot)`. Otherwise, anything that properly isolates the cross-compiler from the host is fine.
Create and move into a build folder, then configure:
```bash
% ../binutils-$VERSION/configure \
--prefix="$PREFIX" \
--target="sh3eb-elf" \
--with-multilib-list="m3,m4-nofpu" \
--program-prefix="sh-elf-" \
--enable-libssp \
--enable-lto
```
Finally, build and install:
```bash
% make -j$(nproc)
% make install-strip
```
You should add the SuperH sysroot's `bin` to your PATH, or symlink them somewhere else in the PATH. You can then remove the build folder, source folder, and source archive if you need to free up disk space.