Any guides on debugging DMD crash?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Mar 24 17:48:37 UTC 2020


On Tue, Mar 24, 2020 at 04:11:40PM +0000, DanielG via Digitalmars-d wrote:
> On Monday, 23 March 2020 at 00:17:48 UTC, Arine wrote:
> > You'll probably have better luck using LDC2, which has a tried and
> > proven backend LLVM. It doesn't compile as fast, but I find the few
> > seconds is worth the trade off of not having to deal with as many
> > compiler bugs like the one you've found here.
[...]
> I would love for my code to be compatible with all D compilers, and
> have the speed benefit of prototyping with DMD for myself, but I'm not
> too keen on becoming a compiler spelunker given all the other claims
> on my time. (For what it's worth I'm not doing anything fancy or
> esoteric - just bad luck, I guess)

There's ldmd2, an LDC wrapper that works more-or-less as a drop-in
replacement for dmd.  Unless you're using esoteric DMD command-line
options, you can essentially just replace 'dmd' with 'ldmd2' and it
should Just Work(tm).  For GDC, there's also a similar wrapper for the
same purpose.


> So I'm curious if other devs doggedly pursue DMD bugs until they are
> fixed, or if they just throw their hands up and use LDC2. My deeper
> fear is that someday I'm going to hit a frontend bug and won't have
> the skills or capital to get it solved :(

All D compilers currently share the same frontend, so you don't have to
worry about that.  Most DMD bugs being actively fixed are frontend bugs,
and directly benefit the other 2 compilers.  Only a small number of
people are actively working on the DMD backend (mainly just Walter, plus
one or two others occasionally), and its codegen quality, sorry to say,
leaves a lot to be desired.  Its only redeeming quality currently is its
lightning speed.

I've recently switched to LDC for all of my new D projects, and use DMD
only occasionally for single-module development because of its quick
turn-around time (dmd -i -unittest -main is great for fast development
of a single module / cluster of related modules). While LDC does add a
few seconds to the compile-time, I find the superior codegen quality to
be more than worth the cost.  Armed with ldmd2, you don't even have to
change your build setup except to substitute 'dmd' with 'ldmd2', for the
most part.  I highly recommend it.


T

-- 
The richest man is not he who has the most, but he who needs the least.


More information about the Digitalmars-d mailing list