working on gdc on Windows

Posted 2021-03-22

Quick post this week but I spent the weekend dipping my toes into gdc development for the first time...

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

gdc on Windows

A random person on the internet posted a link to gcc binaries for Windows, including D support. I downloaded it an tried it but found it had no druntime so at first I asked him to just rebuild with it enabled, but he reported it didn't build. I set out to fix that.

I pretty quickly hit some walls. My first attempt accidentally built gdc inside WSL since I thoughtlessly ran bash to ./configure... and that triggered wsl. Then my next try got nowhere since I was using the wrong shell.

Turns out the best way is to download mingw64's Msys2, then open the mingw 64 msys2, not the msys2 msys window!

In there you can build. First, make a separate build directory, then do ../gcc/configure SETTINGS. The most important settings things for D are --enable-languages=d --enable-libphobos though you can add a bunch of other ones to speed up the build and do other tweaks.

Then it is time to make and be warned, it can take a long time. My Windows box is old and slow but it took hours there. Other people tell me their computers did the from-scratch build in like 15 minutes. Still, it is a fairly slow process so don't expect dmd-like speedy results.

Then you can make install or just run it direct from the build directory by setting your PATH. Like PATH=gcc-build/gcc:$PATH gdc.

But it will fail if you try right now with gcc master! There's some broken stuff upstream (you need binutils master for one thing, a dwarf 5 output bug, but that's not included in the normal build environment download, so need to work around it in gcc) and the gdc fixes aren't in yet, but Iain Buclaw has a branch he's gonna make public soon.

The truth is when I hit trouble, I asked Iain for some help and he provided it... then kept going himself and ended up doing basically all the work! I just lag behind him trying to confirm his fixes work on my computer too.

Anyway what's coming:

  • mingw gdc with full D + stdlib support
  • shared druntime support! dmd and ldc don't have this, but mingw makes it easier to do than the MSVC compatible way, meaning gdc + mingw will be able to do something they can't.
  • upstreaming it all both to druntime and to gcc. We'll then ask the people doing binary distributions to add it meaning users can easily downloading the working gdc for Windows to "just work". Maybe we can even get it in the mingw distribution itself!

It is exciting stuff. gdc is a real asset to D but is often underrated. With these growing distribution channels and some website fixes we're hoping to defeat these misconceptions and get it the recognition it deserves.