[dmd-internals] dmd 2 on OpenBSD 5.1

Konstantin Staver mad.skipjack at gmail.com
Mon Aug 6 06:38:15 PDT 2012

Hi to all!

I want to build dmd2 (git HEAD) with druntime and phobos on OpenBSD
5.1. I failed to build druntime. I found problem with D compiler. D
compiler loops when it tries to optimize code. For example, it doesn't

//// my_mod.d

module my_mod;

void MyFunc()
    int[2] arr;
    for (size_t i =0; i < 2; ++i) {
        arr[i] = 1;

///// end of my_mod.d

I attached gdb output. dmd loops with "while" of doptelem.

Give me a tip about solution of the problem, please. How to debug it correctly?

-------------- next part --------------
$ gdb dmd
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-openbsd5.1"...
(gdb) run -lib -oflib/libdruntime-openbsd32.a -Xfdruntime.json -m32 -O -release -inline -w -Isrc -Iimport -property  test.d 
Starting program: /home/walnut/work/dmd/src/dmd -lib -oflib/libdruntime-openbsd32.a -Xfdruntime.json -m32 -O -release -inline -w -Isrc -Iimport -property  test.d
DMD v2.061 DEBUG
Program received signal SIGINT, Interrupt.
[Switching to process 3726, thread 0x7f88b400]
optelem (e=0x7d7348b0, goal=1) at backend/cgelem.c:4309
4309        elem_debug(e);
Current language:  auto; currently c++
(gdb) bt
#0  optelem (e=0x7d7348b0, goal=1) at backend/cgelem.c:4309
#1  0x1c028157 in optelem (e=0x7d73517c, goal=1) at backend/cgelem.c:4420
#2  0x1c02e85a in doptelem (e=0x7d73517c, goal=5) at backend/cgelem.c:4697
#3  0x1c0d9e07 in elimbasivs (l=0x809d47c0) at backend/gloop.c:3027
#4  0x1c0dbdba in loopiv (l=0x809d47c0) at backend/gloop.c:2127
#5  0x1c0de952 in loopopt () at backend/gloop.c:900
#6  0x1c0e1d2c in optfunc () at backend/go.c:281
#7  0x1c128930 in writefunc2 (sfunc=0x7d7339a4) at backend/out.c:1155
#8  0x1c128b8b in writefunc (sfunc=0x7d7339a4) at backend/out.c:892
#9  0x1c0e0307 in FuncDeclaration::toObjFile (this=0x86a5fe00, multiobj=0) at glue.c:978
#10 0x1c0e0c5d in Module::genobjfile (this=0x8340b400, multiobj=0) at glue.c:356
#11 0x1c0e15d4 in obj_write_deferred (library=0x809d4300) at glue.c:128
#12 0x1c10178c in tryMain (argc=13, argv=0x8b5b4c00) at mars.c:1421
#13 0x1c101969 in main (argc=8932421, argv=0x0) at mars.c:1483

More information about the dmd-internals mailing list