March 5, 2022

Callan Multibus 68k computer - Compiler and libgcc

I have been using the very latest gcc as a m68k cross compiler with good success. Up to a point. I am running Fedora 34 and the following is available as a fedora package I can just install via "dnf".
gcc-m68k-linux-gnu-11.2.1
However, I ran into a problem. For one of my small "bare metal" projects I was compiling some C code that did division and modulo as part of a routine to convert an integer value to a string. This code as getting an m68k "address error" exception. I tracked this down to the modsi3 function which is part of "libgcc". It looks to me like the libgcc that ships with the compiler built by Fedora has only a libgcc that is for the mc68020 or such processor and is using instructions that give the plain old mc68000 indigestion.

The answer of course is to find a gcc that is suitable for the mc68000. I really have two options. One is to rebuild gcc with "multilib" support so there are a variety of different libgcc available. The other is to find the source for libgcc and build it off to the side myself, or at least part of libgcc which includes these routines.

I have source for gcc from all through history on my machine. Two candidates for what I am looking for are:

gcc-2.95.3/gcc/config/m68k/lb1sf68.asm
gcc-4.7.2/libgcc/config/m68k/lb1sf68.S

My solution

I robbed lb1sf68.S from gcc-2.95.3 along with the Makefile infrastructure to support it. I then generated libm68k.a, which has only the integer routines I need. The bulk of the code is software floating point, which I do not want or need.

This works just fine and solves my problem.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org