Porting gdc/dmd to Hurd

yelninei yelninei at tutamail.com
Thu Mar 19 16:41:41 UTC 2026


Hi everyone,

Over the last couple of weeks I have been trying to make gdc/dmd 
work on GNU Hurd.

This mostly involved porting druntime, wiring things up in the 
gcc/dmd build system and telling dmd about the new OS.

With 3 different versions of the same patch I am now able to 
bootstrap dmd with

gdc-11 -> gdc-14 -> gdmd -> dmd-2.112 -> dmd-2.112

I have not looked yet at what would be needed for ldc but I hope 
it is only minimal additional changes.


It does not work 100% correctly yet as some dmd/phobos/druntime 
tests still segfault.

One thing that I am currently a bit stuck on is the following 
which is a simplification of `runnable_cxx/cabi.d` test.

It currently crashes either in the c code or when D tries to use 
the value returned from C on the 32bit Hurd variant, the 64bit 
one does not seem to have the problem.
The same code compiled with my gdc works as expected.

For the codegen i have not done anything special other than 
adding hurd to the existing linux/bsd cases

```d
import core.stdc.stdio;

struct Foo1 { char c; }
extern (C) Foo1 ctest1();

void main()
{
   Foo1 f1 = ctest1();
   printf("%d\n", f1.c);
   assert(f1.c == 3);
}

```

where ctest1 is

``` c
struct Foo1 { char c; };

struct Foo1 ctest1()
{
     struct Foo1 f;

     f.c = 3;
     return f;
}
```

I must admit I am a bit lost in the codegen part in dmd, if 
anyone has some hints where I should look to fix this, that would 
be great.

Id love to upstream my changes but I would need to clean them up 
a bit as so far I have prioritized functionality over style, etc. 
For the same reason I dont want to link to my changes yet but 
they are public if one knows where to look.


More information about the Digitalmars-d mailing list