D Programming language port

In continuation of the Wheel Reinventing thread, I’m looking at porting D as a means of having a friendly backend to a Visual Language editor that saves its sources in XML.

My first step at trying to port it was looking at building it from source on Linux as a means of cross-compiling it with itself. It’s a self-hosted language so this is a necessary step. After I discovered that the included makefiles are a deprecated build system and the DUB packager is the preferred way to build anything with D, I’m not as hopeful as I was. This requires a person to be fluent in D to be able to even attempt a port.

I like what I see of the language but I need to study farther to get anywhere. My method involved using the Linux package manager on Manjaro to download the LLVM-based LDC and its runtime, then trying to build the original Digital Mars DMD compiler which includes the runtimes. The good news is that POSIX compliant builds are lumped together enough that they are unlikely to use system-specific implementations of anything.

12 Likes

If I remember correctly an old version of DMD is in haikuports, this old version compiles from C and C++ instead of D, so you could also start from there.
Last time I checked, it successfully builds the compiler (which could be used to create newer versions of DMD), but several things need to be fixed in the recipe first. From what I remember :

  • No DUB is generated
  • issue with config file location

May be a lower effort than cross compiling GDC or LDC?

3 Likes

I have not looked into D lang deeply before. If there are new option to make Haiku native software, it is great. (I’m interested in try using D directly instead of C++.)

So I just read briefly about how D interfacing C++ API.

As far as I look sample code, creating Interface Kit classes and calling them requires some boilerplate code.

So filling the gap by processor of your system’s XML may work well.

Using it from D directly may want some another codegen solution. Maybe it reads C++ header with libclang or so, and generate class decls for D.

Are there such a solution inDlanguage community?

1 Like

Why dont you enable the D lang support in the GCC recipe? AFAIR it builds fine. (You have to split out the new files into an own subpackage, refer the gfortran and objc subpackage definition for more info).

1 Like

Because it doesn’t include the runtimes. It takes more than a compiler to build a language.

1 Like

I was going to suggest the same. Then you can perhaps build the runtime with the compiled gdc?

I was going to bundle the runtime with GDC. It appears that DMD may lead development and the LDC and GDC follow version-wise. When trying something out for the first time on Linux, where all 3 are supported, I chose to see what I could build with unmodified build scripts.

Tuning the dmd 2.067.1 port to compile again was actually quite easy, but I have not enough knowledge (yet?) on receipe making to correct the error (phobos files, the d standard library, are not found) :

clip-2023-09-03

Having this old version of dmd compiled from c/c++ will allow us to bootstrap up to date dmd/gdc/ldc which all require a D compiler.

4 Likes

They just had a d-lang conference in London last week. This should have been presented there.

This is just de compiler which is useless by itself. Still needs d-runtime and phobos to be ported, so not ready to announce anything yet.
Will have a look at d-runtime in the coming weeks.

3 Likes