Amiga

Using VBCC as an Amiga Cross-Compiler in Linux

For a while I was using GCC as a cross-compiler to write software for Amigas. This was familiar territory for me having used GCC for Linux applications for many years. Unfortunately I hit a very strange bug which appears to be something to do with the compiler output. So I decided it was time for a change, something that was designed for Amiga cross-compiling.

The Bug

I have been developing a GUI application which allows someone to flash Kickstart ROMs onto a special board. It is part of the 68000 Relocator Flash Kickstart project. The software has been a little complicated to write because I’ve had to make it compatible with Workbench 1.3. Whilst running some tests I found that whilst the application ran great in Workbench 2.0 and 3.1, in 1.3 it would immediately crash the entire machine if it was executed using an icon. But loading using the shell worked fine.

I spent a few hours trying to dig into what is happening here and talked to a few people who have worked with Amigas much longer than me. We figured that it was an issue in the startup code generated by the cross-compiler. So I decided to switch compiler to one that was designed to work with Amigas, that compiler is VBCC.

Installation

When installing the Amiga GCC compiler it automatically installs VBCC as well. This gave me the starting base for what was needed. There are two more things that are needed:

  • The kick13 compiler target, near the bottom of this page
  • AmigaOS NDK 1.3 (look for ndk13.lha online)

The these things can be extracted anywhere. I extracted them in /opt/amiga/vbcc and moved them around with directory layout below:

/opt/amiga/vbcc
├── config
├── include
│   ├── ndk13
│   │   ├── devices
│   │   ├── exec
│   │   ├── graphics
│   │   ├── hardware
│   │   ├── intuition
│   │   ├── libraries
│   │   ├── resources
│   │   └── workbench
│   └── NDK_1.3
│       ├── Autodocs1.3
│       │   ├── DevicesA-K
│       │   ├── DevicesL-Z
│       │   ├── FinalUpdate
│       │   │   └── Includes
│       │   ├── LibrariesA-K
│       │   ├── LibrariesL-Z
│       │   ├── LinkerLibs
│       │   └── Resources
│       ├── Includes1.3
│       │   └── include.i
│       │       ├── devices
│       │       ├── exec
│       │       ├── graphics
│       │       ├── hardware
│       │       ├── intuition
│       │       ├── libraries
│       │       ├── resources
│       │       └── workbench
│       ├── Include-Strip1.3
│       │   ├── fd1.3
│       │   ├── include.h
│       │   │   ├── devices
│       │   │   ├── exec
│       │   │   ├── graphics
│       │   │   ├── hardware
│       │   │   ├── intuition
│       │   │   ├── libraries
│       │   │   ├── resources
│       │   │   └── workbench
│       │   ├── include.i
│       │   │   ├── devices
│       │   │   ├── exec
│       │   │   ├── graphics
│       │   │   ├── hardware
│       │   │   ├── intuition
│       │   │   ├── libraries
│       │   │   ├── resources
│       │   │   └── workbench
│       │   ├── lib
│       │   ├── offs1.3
│       │   ├── startups
│       │   │   ├── startup1.2
│       │   │   └── startup1.3
│       │   │       └── oldrstart
│       │   └── util
│       └── Read-Me1.3
│           ├── 1.2ReadMes
│           │   ├── devices
│           │   └── libraries
│           ├── A2024Docs
│           ├── AutoBoot1.3
│           ├── Autodocs1.3
│           └── Printer1.3
│               ├── Driver.Examples
│               │   └── src
│               │       ├── colormaster
│               │       ├── colormaster2
│               │       ├── epsonQ
│               │       ├── epsonX
│               │       ├── hp
│               │       ├── okimate20
│               │       └── xerox_4020
│               └── include
└── targets
    ├── m68k-kick13
    │   ├── include
    │   │   ├── clib
    │   │   ├── inline
    │   │   └── proto
    │   └── lib
    └── vbcc_target_m68k-amigaos
        ├── config
        └── targets
            └── m68k-amigaos
                ├── include
                │   ├── inline
                │   └── proto
                └── lib

Setup

VBCC works with config files which you select at compile time to set all the compiler options and paths. The kick13 target comes with a few, but they are designed to run directly on the Amiga itself. The important one is /opt/amiga/vbcc/config/kick13 and I modified it to look like this to fix the paths:

-cc=vbccm68k -quiet -hunkdebug %s -o= %s %s -O=%ld -no-cpp-warn -I/opt/amiga/vbcc/targets/m68k-kick13/include/ -I/opt/amiga/vbcc/include/ndk13/
-ccv=vbccm68k -hunkdebug %s -o= %s %s -O=%ld -no-cpp-warn -I/opt/amiga/vbcc/targets/m68k-kick13/include/ -I/opt/amiga/vbcc/include/ndk13/
-as=vasmm68k_mot -quiet -Fhunk -kick1hunks -nowarn=62 %s -o %s
-asv=vasmm68k_mot -Fhunk -kick1hunks -nowarn=62 %s -o %s
-rm=rm %s
-rmv=rm %s
-ld=vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib -Z -mrel /opt/amiga/vbcc/targets/m68k-kick13/lib/startup.o %s %s -L/opt/amiga/vbcc/targets/m68k-kick13/lib -lvc -o %s
-l2=vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib -Z -mrel %s %s -L/opt/amiga/vbcc/targets/m68k-kick13/lib  -o %s
-ldv=vlink -bamigahunk -t -x -Bstatic -Cvbcc -nostdlib -Z -mrel /opt/amiga/vbcc/targets/m68k-kick13/lib/startup.o %s %s -L/opt/amiga/vbcc/targets/m68k-kick13/lib -lvc -o %s
-l2v=vlink -bamigahunk -t -x -Bstatic -Cvbcc -nostdlib -Z -mrel %s %s -L/opt/amiga/vbcc/targets/m68k-kick13/lib/ -o %s
-ldnodb=-s
-ul=-l%s
-cf=-F%s
-ml=500

Finally you need to tell VBCC where this all is. The compiler automatically finds the configs and targets directories using an environment variable called VBCC. I use zsh for a shell in Linux so at the end of my ~/.zshrc file I added this:

# Amiga VBCC
export VBCC=/opt/amiga/vbcc

Using the Compiler

At the top of my Makefile I set these:

CC=vc +kick13
CFLAGS=-c99 -Ireqtools -DNDEBUG -lamiga -lauto

The CC line states to invoke the vc compiler and use the kick13 config that we setup above. For CFLAGS my project was designed to use C99 standard, I’m using the reqtools include path. The -lamiga links to Amiga standard library and -lauto links to a VBCC library which contains the library bases.

Conclusion

I had to tweak a few things to make them compatible with VBCC, luckily the error messages gave away most of it. I used the reqtoolsnb.lib library from the SAS-C glue code for the Reqtools stubs instead of the glue code for GCC.

Once I got the compilation to succeed I tried it out on Workbench 1.3 and I can finally start using an icon. I’ll be sticking to VBCC for cross-compiling for now on. Unfortunately I didn’t take a photo of that, but this is what it normally looks like in an emulator:

LinuxJedi

Recent Posts

The Legend Continues: Amiga 1000 Keyboard Revival

I have restored the boxed Amiga 1000 main unit and the mice that came with…

2 days ago

Amiga 4000 Repair: This one was just weird

I was recently sent an Amiga 4000 motherboard repair. It should have been quite straightforward,…

3 days ago

Unboxing the Legend Continues: Amiga 1000 Mouse Restoration.

I recently received a boxed Amiga 1000 which was in excellent condition, but required a…

1 week ago

Unboxing a Legend: Amiga 1000

I have a local friend who is a private collector of vintage computers and consoles,…

2 weeks ago

Amiga 4000 With Lots of Little Problems

I’ve had a few people send me things in to repair lately. Amongst these was…

2 months ago

Amiga A3640 CPU Card Repair

Lately, I've been very busy, but haven't had many interesting things to blog about happen.…

2 months ago