D on Dreamcast

From dreamcast.wiki
Jump to navigation Jump to search

Introduction

D is a flexible systems programming language, which allows writing fast software, fast. Getting DLang on the Dreamcast is in of itself simple, using the GCC D compiler (GDC), but as of current the D runtime and standard library are unavailable. As such alternatives need to be used, without the garbage collector you'd find in stock DLang.

Currently, building the compiler on Windows is very difficult and it's recommended to build it on macOS or Linux, or via WSL.

Prerequisites

A few utilities for D are needed to get started, namely dub, the D package manager. You can get this by going to https://dlang.org and downloading the DMD or LDC2 distributions of D. You will not need the compilers or standard libraries that come with either package for dreamcast development, but they may be useful for developing tooling. Dub comes bundled with both DMD and LDC2, there's no precompiled GDC package and it is considerably more difficult to get a full D environment set up the manual route, so it is not recommended.

You will additionally need to get the dc-chain script installed, together with a copy of git. See (the C/C++) getting started guide and follow it until you reach the Downloading and compiling the toolchain section.

Building the D cross compiler

Once you are ready to build the SH toolchain, you can begin the compilation process with D support enabled by running

make enable_d=1

Once this is done you can continue following the instructions in the Getting Started guide.

Post Build

You can use the dkos and numem packages to develop software for the Dreamcast, do note that DKOS is still in development and some features are still missing, contributions are welcome!

DKOS depends on a custom runtime called tinyd-rt, which automatically should get fetched on build.