Skip to content

Adding a binutils port to adtools

migthymax edited this page Feb 20, 2025 · 1 revision

Here I will describe how a successful port of a specific binutils version can be packaged and contribute to the adtools project. That is needed so that building a tool chain for ppc-amigaos can be easily be done from within the adtools project.

Preparation

This how-to assumes that everything is made relative to a directory names projects. So we start with a shell having the directory as the current working directory. Additional we want to package a specific binutils version, in this case we use version 2.41. All the specific ppc-amigaos adoption has taken place in the branch ppc-amigaos-2_41. First we need to checkout the adtools project, and the branch ppc-amigaos-2_41 of the binutils project:

~projects$ git clone https://github.com/AmigaLabs/adtools.git
~projects$ git clone -b ppc-amigaos-2_41 https://github.com/AmigaLabs/binutils-gdb.git

Setup adtools for new binutils

Now we will modify the adtools project, so that it know how to handle the new binutils version. To do that we need to setup gild within adtools:

~projects$ cd adtools
~projects/adtools$ git submodule init
~projects/adtools$ git submodule update

After that, we tell adtools the new binutils version, adding needed information in the series within the binutils directory.

~projects/adtools$ cd binutils
~projects/adtools/binutils$ mkdir -p 2.41/patches
~projects/adtools/binutils$ vi series

The content of the series file looks something like this:

2.23.2  binutils-2_23_2 http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2

We need to add a line which describes the version of binutils we want to add patches for. In our case the line to be added looks like this:

2.41    binutils-2_41   http://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.bz2

So the final content of series looks like this:

2.23.2  binutils-2_23_2 http://ftp.gnu.org/gnu/binutils/binutils-2.23.2.tar.bz2
2.41    binutils-2_41   http://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.bz2

Creates diff files for ppc-amigaos modification on binutils

Change to the binutils project, search for the first commit regarding ppc-amigaos specific changes:

~projects/adtools$ cd ..
~projects$ cd binutils
~projects/binutils$ git log

Now skim through the log and lock for the first ppc-amigaos specific commit, in our case it is the following commit with id 34db58af31ba7bbf20f765341fe6c7a53a5aff91:

commit 34db58af31ba7bbf20f765341fe6c7a53a5aff91
Author: MigthyMax <migthymax1977@gmail.com>
Date:   Tue Jan 10 11:44:25 2023 +0100

    Update VS Code devcontainer files

commit 32778522c7d8777803c88684b8e428ee729f0b22
Author: Nick Clifton <nickc@redhat.com>
Date:   Sat Jan 14 13:52:46 2023 +0000

    Fix snafu in version number.  Regenerate files

Starting with that commit we create a diffs.diff file containing all made changes to binutils:

git diff 34db58af31ba7bbf20f765341fe6c7a53a5aff91... > diffs.diff

Prepare upstream binutils repository in adtools

Using gild list should list our newly added binutils version, if not something went wrong in the previously chapters.

~projects/binutils$ cd ..
~projects$ cd adtools
~projects/adtools$ gild/bin/gild list
binutils 2.23.2
binutils 2.41
coreutils 5.2
coreutils 8.27
gcc 4.9
gcc 5
gcc 6
gcc 8
gcc 9
gcc 10
gcc 11
gnulib for-coreutils-8.27

So our version is listed, next checkout the upstream binutils repsoitory:

~projects/adtools$ gild/bin/gild checkout binutils 2.4.1
Cloning into 'repo'...
....

Apply diffs to adtools binutils repository

Now we apply the diffs.diff file from the binutils project on the binutils repository of the adtools project:

~projects/adtools$ cd binutils/repo
~projects/adtools/binutils/repo$ git apply ../../../binutils/diffs.diff

All made modifications and added files need to be put under git control:

~projects/adtools/binutils/repo$ git add -A .

Nest commit everything with a smart and good commit message enter via an editor of choice, here emacs:

~projects/adtools/binutils/repo$ EDITOR=/usr/bin/emacs git commit
hint: Waiting for your editor to close the file...

Package commit to the adtools binutils repo as adtools patches

~projects/adtools/binutils/repo$ cd ../..
~projects/adtools$ gild/bin/gild genpatch binutils 2.41

The commit should no be listed as patch in the ~projects/adtools/binutils/2.41/patches! The last step to be done is to take the made modification to the adtools project under git control and commit&push the changes.