A few years ago I created a bare metal demo on an ARM Cortex-M4
microcontroller entirely in D. It was just a demonstration that
one could do bare metal programming for microcontrollers in D
without any dependencies on C or assembly. It was also a proof
of some ideas I had about leveraging compile-time features of D
to generate highly-optimized code (both small and fast) for these
resource constrained systems. I hit a wall, however, with Issue
14758, and ultimately abandoned D for other alternatives.
Well, that issue was recently fixed in GDC . In addition, he
GDC developers did some work to reduce the number of phony stubs
one had to add to the runtime to get a build , removed the
"shared is volatile" hack, and implemented the
`volatileLoad/Store` intrinsics so I no longer need to do
volatile access in assembly. So, I decided to give it another
try, and updated that demo. You can see the results at
A few observations:
* It is a better experience than it was a few years ago. Fewer
dirty hacks are required, and the resulting binary is small and
* Everything is in D (inline assembly is D). There's no need for
any C or assembly startup code, and no need for silly things like
-betterC (i.e. -worseD). If you don't want the overhead from a
feature of D, don't use it.
* Compile times are quite slow (about 1 minute to get a 3kB
binary). Some discussion about that is taking place on the GDC
* -O2 and -O3 give me a broken binary, but -O0, -O1, and -Os work
I'm not sure where I'll go from here. I'm interested in helping
an amputee play the drums again, and building my own mechanical
keyboard, so I probably won't be spending much more time on this
LCD demo, except maybe to help compiler devs debug some issues.
However, I might spend some more time with D in the near future,
and see how far I can take this. I'm still not as excited as I
once was, but it's nice to see these improvements.
Anyway, Well done, GDC!
 - TypeInfo causes excessive binary bloat -
 - Put the TypeInfo name field into a static var -
 - Refactor and reformat typeinfo.cc -
 - Slow compile-time discussion at GDC forum -