<h2>D on OpenBSD</h2>

<h3>Step 1: do a normal install OpenBSD 6.9.</h3>

If you're installing a later version, you can probably skip step #2.

<h3>Step 2: update to OpenBSD-current from 6.9</h3>

<verbatim>
# sysupgrade -s
</verbatim>

<h3>Step 3: install gdc</h3>

<verbatim>
# pkg_add gdc
</verbatim>

<h3>Step 4: add 'gdc' to your PATH</h3>

<verbatim>
$ mkdir ~/bin
$ ln -s
</verbatim>

<h3>Step 5: add 'gdmd' to your PATH</h3>

<verbatim>
# pkg_add git
$ mkdir ~/dlang
$ cd ~/dlang
$ git clone
$ cp -pv gdmd/dmd-script ~/bin
</verbatim>

To make these available to any user on the system, a better directory. Just note that the math/gbc package also tries to install a

<h3>Step 6: raise user memory limits</h3>

If you don't want to have to compile D programs as root. The defaults are too low for building dub in particular.

<verbatim>
# cat >> <<'EOF'

#
# Login class for users that will be building D programs.
#
dmd:\
        :datasie-cur=infinity:\
        :datasize-max=infinity:\
        :tc=staff:

EOF
# usermod -L dmd USER
</verbatim>

You'll may need to log out and log back in to get a session with the new limits. On a desktop with 32GB of RAM and 32GB of swap, 'ulimit -a' reported a data(kbytes) value of 32GB.

<h3>Step 7: build and install dub</h3>

<verbatim>
$ cd ~/dlang
$ git clone
$ cd dub
$ gdc -O -o build build.d
$ ./build
Building dub using gdmd (dflags: ["-g", "-O", "-w"]), this may take a while...
DUB has been built as:
You may want to run `sudo ln -s now
</verbatim>

<h3>Step 8: confirm dub actually works</h3>

... presently, most functions segfault pretty early on.

<verbatim>
$ echo 'void main(){writeln("test");}' | dub -q run dfmt -- --brace_style=otbs
Segmentation fault (core dumped)
</verbatim>

<h3>Step 9: get D tools</h3>

The OpenBSD gdc package just gives you an 'egdc' bin. You'll probably want at least ddemangle and rdmd

<verbatim>
$ cd ~/dlang
$ git clone
$ cd tools
$ perl -i -lpe 's/"-v", if rdmd.d
$ gdc -O2 -o rdmd.d
$ rdmd --eval 'writeln("it works")'
it works
$ gdc -O2 -o ddemangle.d
$ objdump -dwr --no-show-raw-insn -m1 std.conv
  18f72d:       jmp    18f730 <_D3std4conv__T10emplaceRefTAyaTQeTQhZQxFKQoKQrZ1S9__xtoHashFNbNeKxSQCnQCm__TQCkTQCbTQCfTQCjZQDaFKQCsKQCwZQCgZm>
shadow$ objdump -dwr --no-show-raw-insn -m1 std.conv|ddemangle
  18f72d:       jmp    18f730 <nothrow @trusted ulong std.conv.emplaceRef!(immutable(char)[], immutable(char)[], immutable(char)[]).emplaceRef(ref immutable(char)[], ref immutable(char)[]).S.__xtoHash(ref const(std.conv.emplaceRef!(immutable(char)[], immutable(char)[], immutable(char)[]).emplaceRef(ref immutable(char)[], ref immutable(char)[]).S))>
</verbatim>

That perl line strips a -v (verbose) flag out of the command that rdmd passes to gdmd. I haven't looked into why this produces tons of noisy output on OpenBSD but not on Linux, but it's probably a bug.

<h3>Step 10: build dmd?</h3>

It fails right now, but why not give it a try?

<verbatim>
# pkg_add gmake
$ cd ~/dlang
$ for x in dmd druntime phobos; do git clone done
$ ( cd dmd; HOST_DMD=gdmd gmake -f posix.mak )
$ ( cd druntime; HOST_DMD=gdmd gmake -f posix.mak )
$ ( cd phobos; HOST_DMD=gdmd gmake -f posix.mak )
</verbatim>