61

I would quite like to resurrect my openkick project. As I note on that project's README.md, it is stalled because GNU GCC is not fit for purpose.

Sadly, there do not seem to be any other modern compilers which still have (or ever had) m68k support. The LLVM backend appeared to be my best bet but the architecture-specific code-generator is woefully underdocumented and rather brittle and my attempts to add a m68k backend are not promising. There are already a handful of incomplete m68k backends on github (e.g. kwaters/llvm-m68k, SamuraiCrow/llvm-m68k and Peylow/llvm), but those can barely even process trivial straight-line code and are on a par with my own efforts.

So is there another solution that I've missed? There seem to be (at least) three options:

  • Find a port of gcc that supports regparm on m68k and actually pays attention to -fomit-frame-pointer so that it doesn't interfere with the Amiga's standard library-calling convention;
  • Find a more complete m68k backend for LLVM; or
  • Find another compiler that has a decent m68k backend.

I would strongly prefer that the compiler understand C++11, which both GCC and clang support, and can be made to run on MacOS. I can backport my code to C++98 if necessary, but booting up an emulator or VM to run some obscure ancient executables would foul up my workflow.


Edit 2016-05-22 1314 CEST:

rrrzx pointed out vbcc in a comment, so I gave it a spin. The upside is that it supports register parameters and doesn't take A6 for its own purposes, so it can be used to cross-compile Amiga binaries without having to fight the compiler as is the case with gcc. The downside is that it is C-only, and its optimiser and code generator are pretty dire.


Edit 2018-08-18 1817 CEST:

My eventual solution was to bodge regparm support into gcc, and it has proven reliable enough for my purposes. You can find it in the mooli/gcc-amiga repository on GitHub.

11
  • 6
    I think the path of least resistance is to port the AmigaOS-specific parts of the old GCC 2.95 port up to GCC 4.9, which is the last GCC to natively support m68k (even though the generated code is worse, but that's often not the most important thing.) But it's a good question. I really hope that someone will come up with a great answer.
    – pipe
    Commented May 22, 2016 at 0:43
  • 2
    I've been using GCC for m68k successfully for my Atari Falcon but I forget which build. I'll check it out later when I'm back on my PC.
    – Matt Lacey
    Commented May 22, 2016 at 3:07
  • 9
    I was discussing this same problem with a friend last week, and one idea that would be nice is to make a GCC or LLVM backend that will generate compliant oldschool ANSI-C from any high-level language. That file can then be run through the native compiler to generate an executable. This would also be useful for other legacy platforms.
    – pipe
    Commented May 22, 2016 at 4:43
  • 3
    None of these options may meet your requirements, but for completeness sake, the ones I know are: gcc 2.95 in amigaos-cross-toolchain, gcc 3.4.6 in the netsurf toolchain (but you need to do a little work to enable g++, and is good enough to compile ScummVM 1.8.0 at least), gcc 4.6.4 in the AROS toolchain (ELF files are generated, so you need to run elf2hunk on the executable), and VBCC (C only and C99 support is incomplete).
    – rcntxtlztn
    Commented May 22, 2016 at 7:05
  • 4
    Commenting as this is more conjecture than an answer, but I read somewhere that pcc - Portable C Compiler - was used to build parts of the very first Amiga OS sources. It was resurrected recently (although I'm not sure if it's very active) at pcc.ludd.ltu.se. I quick nosey at the source code shows that it supports an m68k backend. May be worth a look. Commented May 23, 2016 at 15:27

8 Answers 8

16

Half a year ago, I've started a M680x0 port of LLVM. It is still at an early stage, but currently it is able to emit linkable/relocatable (no tls) object files that can be linked with GNU ld against glibc or newlib. ISA is limited to M68000 but is easily extensible. Also C++ support is rather questionable but if you are familiar with LLVM you can add it.

If interested you can check it out here: https://github.com/M680x0

2
  • So is the C support more or less complete and stable?
    – JeremyP
    Commented May 4, 2017 at 10:15
  • It can cross-compile GNU Hello (not your average hello world) executable that you can run on Debian m68k port. As far as I can tell this project covers all c98 features, most of it of course is handled by clang itself, but llvm-wise it has everything you need to compile a C program. Commented May 4, 2017 at 11:14
11

Take a look at https://github.com/bebbo/amiga-gcc which are GCC 6.5 cross-compiler toolchains for Windows, Linux, and Mac OS X targeting AmigaOS 3. There's an ongoing discussion about it here.

Edit: Thanks for the update, @bebbo!

0
4

You should try chairwpz, if you didn't already. It manifests as as a decent toolchain for linux/MacOS.

https://github.com/cahirwpz/amigaos-cross-toolchain

1
  • 2
    Thanks for this! This answer would be even better if you included some information about the software as well; at the moment this is largely a link-only answer (albeit a useful one!).
    – wizzwizz4
    Commented Nov 14, 2016 at 17:13
4

One approach you may be interested in that I recently saw somebody else using for working on a platform with no modern C or C++ compiler support was to use LLVM in its output-to-C-code mode, and then process the resulting C code through the original native compiler. This apparently meant they could use modern C and C++ features and they were able to benefit from at least some of LLVM's optimization capacity. Might be worth a try.

3
  • That's a pretty neat idea. But is there a suitable compiler that outputs 68k executables good for AmigaOS. Commented Oct 20, 2017 at 11:53
  • @Wilson The question mentions vbcc as a possibility except for not supporting modern language versions and poor optimization; this approach would definitely resolve the lack of support for modern standards and would also probably improve the situation regarding optimization.
    – Jules
    Commented Oct 21, 2017 at 1:05
  • If I understand correctly, the C backend has been removed from LLVM due to code-rot. That really is a shame.
    – Desty
    Commented Sep 7, 2019 at 23:58
3

This might help a bunch: I've posted a very detailed guide on how to create (from source) an Amiga OS 4.x / PowerPC "adtools" cross-compiling gcc/g++ 5.4.x toolchain; hosted inside either a Cygwin32/Cygwin64 environment or inside a Bash-on-Ubuntu-on-Windows/Windows Subsystem for Linux environment on Windows 10.

That guide is found here:

How-To Create a Cygwin/Bash-on-Ubuntu-on-Windows adtools (cyg-adtools/uwin-adtools) Cross-Compiling Amiga OS4.x Toolchain on Windows 10

I've also posted another step-by-step guide on how to use that cyg-adtools/uwin-adtools toolchain with MS Visual Studio 2017. That second guide is found here:

Using Visual Studio 2017 with a Cygwin-Based Cross-Compiling Amiga OS 4.x adtools Toolchain on Windows 10

I note both those guides here, because they're brand new instructions published in October of 2017, showing how to build the official "adtools" toolchain for OS4.x, and I think they'll work with only minor changes for the OS3.x toolchain as well -- I've simply not tried, though.

2
  • 2
    These are great for PPC — but the OP asked about 68k
    – scruss
    Commented Oct 19, 2017 at 15:42
  • Welcome to Retrocomputing Stack Exchange. Please read the tour. Answers on this site are expected to be self-contained, so could you please provide a summary of your (excellent!) guides in addition to the link to the full version.
    – wizzwizz4
    Commented Oct 19, 2017 at 16:06
3

A all-in-one package does that very well with state-of-the-art 68k gcc:

https://github.com/BartmanAbyss/vscode-amiga-debug

It includes a Visual Studio Code plugin, gcc 11 68k compiler, the emulator and attached debugger to test the code, and a sample project, among other goodies

It's been used to create a few games recently, some even using C++ 2020 idioms.

The "only" limitation is that standard C library isn't included, so no fopen, printf..., so it's not going to be easy, say, to port MAME with it, but it's possible to open AmigaOS libraries and use them (dos.library) and possibly wrap a minimal C library around it.

It's also possible to create executables with all assets included, so no need to read or write files, so who needs DOS?

Tiny Bobble and other abyss creations that use this toolchain are built that way.

1

Free Pascal seems to have Amiga Motorola 68K support both as a native compiler and as a cross-compiler.

2
  • The questioner's program is written in C++.
    – JdeBP
    Commented Apr 25, 2019 at 12:19
  • @JdeBP You're right, my bad!
    – cyco130
    Commented Apr 25, 2019 at 15:18
0

Try this one though it only runs in windows, unfortunately I don't know what backend it uses: http://amidevcpp.amiga-world.de/index.php?HR_LANG=english

3
  • 1
    That fails on "booting up an emulator or VM to run some obscure ancient executables would foul up my workflow"; I don't develop on Windows unless somebody is paying me a lot of money to do so. Its business end is Cygwin, so it'll be using gcc, which I have determined is also not suitable.
    – pndc
    Commented Jul 17, 2016 at 9:56
  • Sorry, I misunderstood that you didn't mind working in a VM. Commented Jul 17, 2016 at 14:17
  • amidevcpp uses an old 68k gcc. It's useable, even has a gui based on an old code::blocks version IIRC but now rendered obsolete by more modern solutions like bebbo & Bartman toolchains. Commented Apr 20, 2022 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .