128 points · by emptybits · 6y ago · 122 comments
> https://www.youtube.com/watch?v=-6zXXPRl-QI
Slides can be found here: http://m68k.info/assets/LLVM-Backend-for-M68k-Overview-and-S...
And a Bountysource campaign to support the project here:
> https://www.bountysource.com/issues/90829856-llvm-complete-t...
Disclaimer: I'm one of the people behind this project but not the main developer. So funds are going to the developer, not me.
On the other hand there is Small Device C Compiler (SDCC) project that provides a decent compiler for Z80 CPU. There is also cc65 for 6502 CPUs.
The strangest thing is that Free Pascal seems to support 68k out of the box (https://www.freepascal.org/) and also AVR and bunch of other archs.
A thought occurs to me: would it be possible to use that compiler to bootstrap your way to a modern C dialect? At one point, there were no C89 compilers. So, one would have to write a C89 compiler in K&R. Or am I failing to appreciate just how much work it would be?
However, a much more efficient approach would be to add support for older architectures to a modern compiler. Then you can build binaries via cross-compilation, or cross-compile the compiler itself to get a modern self-compiler on an old system.
You don't need to. SmallC is a cross-compiler, not a self-hosting compiler; it runs on a modern computer, not an 8085. If you wanted to modify SmallC to accept modern C syntax, you can do that without "bootstrapping" anything.
https://www.phoronix.com/scan.php?page=news_item&px=GCC-11-m...
If you want to limit your retrocomputer design to only parts that are still manufactured, like I do: The only cpu choices appear to be: Z80, 68c02 and 68c816
But it's not recommended for new designs.
https://www.nxp.com/products/processors-and-microcontrollers...
The Julia folks had resurrected the C backend to LLVM at least once, it is also a possibility.
I work on a OS kernel (non-Linux), and in my view, we should support x86_64, arm64, and maybe ppc64le. But instead we have all sorts of 32b legacy hobbiest platforms where there are maybe 3 machines in the world running on them. These platforms make it harder to test changes, simply by the fact that it takes regression tests longer to compile & run, you have to build/install more cross tools, etc. They make it harder to develop because all of a sudden you realize that some standard interface is not implemented on them, and you have regression test failures that you need to work around.
I'm fine with hobby platforms if they play in their own sandbox, but not when they impede development of current systems.
Or maybe I was misunderstanding the point of Theo's post back in 2014 around the discussion of their power bill[1].
LLVM has an "experimental platform" flag that obviates this problem. IIRC, the Linux kernel also has something similar wrt. highly experimental config options.
All of them commercial products and from companies in the US and the UK.
The problem with limited platform support is the lack of competition which helps to lower prices and provides more choice to the customer.
Especially considering the many vulnerabilities Intel CPUs have.
I'm aware that hobbyists platforms are something different, but you excluded many other commercial targets like MIPS, RISC-V, S390 as well.
The key fact is that, in the mid 90s, DEC Alpha was the fastest thing around, and poised to take over the world. It was expected to be the future (until it was killed by corporate incompetence and itanic). That's why I worked on FreeBSD support, and why Linus worked on Linux support. Alpha was also valuable because it was one of the first 64-bit platforms, and found a lot of pointer/int/long bugs on both systems.
There is a big difference between supporting what you expect to be the future of computing to what you know to be the long dead past.
As for bugs, I seem to remember that it had a rather different cache coherency model to Intel, and as you said, was strict about memory alignment.
That's the OP's point. Merging LLVM changes is gated by CI tests for obscure and moribund platforms.
If you have then you tell them you're going to reduce your test case and also that you're going to contact the SystemZ and SPARCV8 maintainers. Maybe your branch won't make it into the tree. Maybe it's your fault or maybe it's theirs; if it's theirs they'll WANT to know about it. Maybe it won't make it into the tree for this release but it might for the next after the bug is fixed.
Development is done in parallel and the middle end always gets improved by being stretched and abused by multiple backends. There are out of tree backends which beat the hell out of GlobalISel (Apple GPU). I'm GLAD that they've done the hard work of beating GlobalISel into shape because it makes it a more stable platform for me. There are in tree backends which are models for cloning (MIPS) even though the vendor is basically an IP holding company.
LLVM stands in contrast to GCC. LLVM was architected as a collection of modular and reusable compiler and toolchain technologies. And then when people actually do that it's a good thing.
Right now LLVM 11 is in RC4, about a month late. There is surprisingly little if any sturm und drang on the developers' list about this slip. Work on LLVM 12 has commenced, in parallel.
But there are modern NXP coldfire parts. The CPU core is mostly binary compatible with 68k, just with some legacy instructions removed.
Coldfire SOCs clock up to about 400mhz and have support for modern devices like ethernet and usb.
They do exist in the form of M683XX microcontrollers.
https://www.researchgate.net/profile/Paul_Carpenter6/publica...
I suspect for many tools, the hobby platform guys are the same as the other patch guys.
> https://buildd.debian.org/status/package.php?p=neovim&suite=...
:-)
It's become unthinkable in the open-source world to not have "one X to rule them all" (in this case X happens to be "compiler", but you see this effect with other tools).
Hobby platforms, especially long-dead ISAs like 68k, should be easy to integrate with LLVM (perhaps through a plugin system? I'm pretty sure both GCC and LLVM have that... you install `gcc` and then you install `gcc-platform-x` or something...) but requiring LLVM core maintainers to think about your obscure arch is not worth it IMO.
https://lists.llvm.org/pipermail/llvm-dev/2020-September/145...
Normally Phoronix is more or less blogspam, but in this case Larabel has actually added some interesting context (history of the backend in LLVM and GCC). So I do not suggest changing the discussion's URL to the ML post.
As a preservationist, I can confirm this would be used. Not much, but it would be used.
So 68k really is comparable to (32-bit) x86.
Edit: Z80 is 8-bit, not 16-bit.
you can still download and compile dcc (http://legacy.obviously.com/dice/ and https://github.com/noname22/NeoDICE) but having first class support in llvm would be very nice.
TFA clearly states gcc support was rescued by hobbyists in the community, it's not being dropped.
Other than dice, there's vbcc[1].
It's a closed -buggy- FPGA reimplementation of something like 68k (nobody outside them knows exactly what, there are rumors it's based on a ColdFire core that was leaked by mistake) with some custom extensions that are underdocumented and have nothing to do with classic Amiga systems.
The entire platform is meant to lock you into their proprietary FPGA core and is totally counter the spirit of the Amiga which was the ultimate hacker's machine.