D on Dreamcast: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
No edit summary
 
Line 13: Line 13:
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.
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. [[Getting Started with Dreamcast development#Setting up and compiling the toolchain with the dc-chain script|See (the C/C++) getting started guide]] and follow it till the Configuring the dc-chain script section.
You will additionally need to get the dc-chain script installed, together with a copy of git. [[Getting Started with Dreamcast development#Setting up and compiling the toolchain with the dc-chain script|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 =
= Building the D cross compiler =
Once you have the D utilities, dc-chain and git installed and you have the dc-chain config available, you will need to modify the build script.
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


Find the following text in config.mk:
Once this is done you can continue following the instructions in the '''Getting Started''' guide.
# Languages (c|c++|objc|obj-c++|d)
# Set the languages to build for sh-elf gcc compilation pass 2. The default is
# to build everything used by all KOS examples; however, only C is actually
# required for KOS itself. D may also be enabled optionally on POSIX platforms
# which have its external dependencies installed.
pass2_languages=c,c++,objc,obj-c++
 
Add D to the pass2_languages like so:
pass2_languages=c,c++,objc,obj-c++,d
 
Once this is done you can continue building and installing the compiler to <code>/opt/toolchains/dc</code>!
 
With this done you should have a functional D toolchain for the SEGA Dreamcast installed.


== Post Build ==
== Post Build ==

Latest revision as of 21:13, 7 May 2024

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.