www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - "Internal error: backend\cod1.c 1895" when trying to build

reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
I'm trying to build DMD, Druntime and Phobos from source.

The resulting dmd.exe fails to compile Phobos with the error "Internal  
error: backend\cod1.c 1895".

It seems to be dependent on my environment... I tried building it in a  
virtual machine, and it worked fine.

Does anyone have any idea what might cause it? Does the ICE count as a  
compiler bug?

-- 
Best regards,
  Vladimir                            mailto:vladimir thecybershadow.net
Jan 29 2011
next sibling parent reply Simon <s.d.hammett gmail.com> writes:
On 30/01/2011 01:11, Vladimir Panteleev wrote:
 I'm trying to build DMD, Druntime and Phobos from source.

 The resulting dmd.exe fails to compile Phobos with the error "Internal
 error: backend\cod1.c 1895".

 It seems to be dependent on my environment... I tried building it in a
 virtual machine, and it worked fine.

 Does anyone have any idea what might cause it? Does the ICE count as a
 compiler bug?

Probably. I found a few bugs by compiling DMD with visual studio. Though that one doesn't look familiar. What you compiling it with and what version of the source? -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Jan 30 2011
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's 
 not a recent regression.)

I compile it every day, and do not see those errors.
Jan 30 2011
parent reply Simon <s.d.hammett gmail.com> writes:
On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460 -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Jan 30 2011
parent reply Simon <s.d.hammett gmail.com> writes:
On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

And for the frond end: http://d.puremagic.com/issues/show_bug.cgi?id=5244 -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk
Jan 30 2011
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Simon wrote:
 On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

And for the frond end: http://d.puremagic.com/issues/show_bug.cgi?id=5244

Thanks for pointing those out. Fixed now.
Jan 30 2011
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Walter Bright (newshound2 digitalmars.com)'s article
 Simon wrote:
 On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

And for the frond end: http://d.puremagic.com/issues/show_bug.cgi?id=5244


Have you considered adding -Wuninitialized to the build WARNINGS? It may help prevent such bugs from happening...
Jan 30 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 On Sun, 30 Jan 2011 22:42:22 +0200, Walter Bright 
 <newshound2 digitalmars.com> wrote:
 
 Simon wrote:
 On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

http://d.puremagic.com/issues/show_bug.cgi?id=5244

Thanks for pointing those out. Fixed now.

Thanks, but it didn't solve my problem.

I didn't think it would. Those issues were completely unrelated. Sorry about that.
 I'd like to emphasize that the problem is with my dmd.exe. If I use the 
 official dmd.exe, Phobos builds fine - so, it looks like I get a 
 slightly broken dmd.exe when I compile it from source.
 
 Does anyone know which git commit is DMD 2.051? I think the best way to 
 find the problem is to compare the released binary with the one I built.

Why not just get the latest dmd if you're interested in compiling from source? Also, if you download dmd 2.051, you'll get the 2.051 source.
Jan 30 2011
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. My 
 version and the one from the .zip seem to differ in many small ways. The 
 first difference is that in main(), the .zip version calls a function to 
 get the address of errno, while my .exe accesses a variable directly.

Check your dmc's errno.h. It should call a function.
Jan 30 2011
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
Walter Bright wrote:
 Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. My 
 version and the one from the .zip seem to differ in many small ways. 
 The first difference is that in main(), the .zip version calls a 
 function to get the address of errno, while my .exe accesses a 
 variable directly.

Check your dmc's errno.h. It should call a function.

I should add be sure your INCLUDE is not picking up some other compiler's header files.
Jan 30 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 On Mon, 31 Jan 2011 06:13:54 +0200, Walter Bright 
 <newshound2 digitalmars.com> wrote:
 
 Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. My 
 version and the one from the .zip seem to differ in many small ways. 
 The first difference is that in main(), the .zip version calls a 
 function to get the address of errno, while my .exe accesses a 
 variable directly.

Check your dmc's errno.h. It should call a function.

It's declared as follows: #if defined(_MT) || defined(_DLL) || __cplusplus extern int * __CLIB _errno(void); #define errno (*_errno()) #else extern int __cdecl errno; #endif So, which of _MT or _DLL or __cplusplus should be defined on my machine but aren't?

_MT and __cplusplus
Jan 31 2011
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 On Tue, 01 Feb 2011 00:30:27 +0200, Walter Bright 
 <newshound2 digitalmars.com> wrote:
 
 Vladimir Panteleev wrote:
 On Mon, 31 Jan 2011 06:13:54 +0200, Walter Bright 
 <newshound2 digitalmars.com> wrote:

 Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. 
 My version and the one from the .zip seem to differ in many small 
 ways. The first difference is that in main(), the .zip version 
 calls a function to get the address of errno, while my .exe 
 accesses a variable directly.

Check your dmc's errno.h. It should call a function.



Actually, it's declared in three files: errno.h, stdlib.h and stddef.h. mars.c uses only the last two.
 _MT and __cplusplus

Why should _MT be enabled? There is no -D_MT in win32.mak. Are we using different makefiles? root/async.c sets _MT explicitly, but the example at hand is from mars.c. If I add -D_MT to CFLAGS in the makefile, I still get a lot of differences. The first difference is now one in a function's prologue/epilogue - the binary from the .zip saves/restores the ECX register, while my binary doesn't. The functions are otherwise identical.

This just makes no sense to me. I still suspect your setup is pulling in some other compiler's #include's.
Jan 31 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
Try compiling a small file, like hello world, with the -e -l flags, and email
me 
the resulting .lst file.
Jan 31 2011
parent Walter Bright <newshound2 digitalmars.com> writes:
Vladimir Panteleev wrote:
 On Tue, 01 Feb 2011 05:30:44 +0200, Walter Bright 
 <newshound2 digitalmars.com> wrote:
 
 Try compiling a small file, like hello world, with the -e -l flags, 
 and email me the resulting .lst file.

I found the problem. Both DMC and its header files were outdated. I don't know how I got to the conclusion that it was up-to-date. Sorry for wasting your time.

No problem. I'm just glad it's working for you now. FWIW, I often see issues like this crop up. With D, it'll be linking in an old phobos library that's still lurking on the disk somewhere :-)
Jan 31 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Sun, 30 Jan 2011 13:15:28 +0200, Simon <s.d.hammett gmail.com> wrote:

 On 30/01/2011 01:11, Vladimir Panteleev wrote:
 I'm trying to build DMD, Druntime and Phobos from source.

 The resulting dmd.exe fails to compile Phobos with the error "Internal
 error: backend\cod1.c 1895".

 It seems to be dependent on my environment... I tried building it in a
 virtual machine, and it worked fine.

 Does anyone have any idea what might cause it? Does the ICE count as a
 compiler bug?

Probably. I found a few bugs by compiling DMD with visual studio. Though that one doesn't look familiar. What you compiling it with and what version of the source?

DMC, and latest git. (The problem was there a few months ago, so it's not a recent regression.) -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 30 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Sun, 30 Jan 2011 22:42:22 +0200, Walter Bright  
<newshound2 digitalmars.com> wrote:

 Simon wrote:
 On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

http://d.puremagic.com/issues/show_bug.cgi?id=5244

Thanks for pointing those out. Fixed now.

Thanks, but it didn't solve my problem. I'd like to emphasize that the problem is with my dmd.exe. If I use the official dmd.exe, Phobos builds fine - so, it looks like I get a slightly broken dmd.exe when I compile it from source. Does anyone know which git commit is DMD 2.051? I think the best way to find the problem is to compare the released binary with the one I built. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 30 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Mon, 31 Jan 2011 04:00:55 +0200, Walter Bright  
<newshound2 digitalmars.com> wrote:

 Vladimir Panteleev wrote:
 On Sun, 30 Jan 2011 22:42:22 +0200, Walter Bright  
 <newshound2 digitalmars.com> wrote:

 Simon wrote:
 On 30/01/2011 18:54, Simon wrote:
 On 30/01/2011 18:29, Walter Bright wrote:
 Vladimir Panteleev wrote:
 DMC, and latest git. (The problem was there a few months ago, so  
 it's
 not a recent regression.)

I compile it every day, and do not see those errors.

Sound like use off uninitialised var, as it's environment dependent. There's at least 2 instances of that still outstanding in the backend: http://d.puremagic.com/issues/show_bug.cgi?id=52460

http://d.puremagic.com/issues/show_bug.cgi?id=5244

Thanks for pointing those out. Fixed now.


I didn't think it would. Those issues were completely unrelated. Sorry about that.
 I'd like to emphasize that the problem is with my dmd.exe. If I use the  
 official dmd.exe, Phobos builds fine - so, it looks like I get a  
 slightly broken dmd.exe when I compile it from source.
  Does anyone know which git commit is DMD 2.051? I think the best way  
 to find the problem is to compare the released binary with the one I  
 built.

Why not just get the latest dmd if you're interested in compiling from source? Also, if you download dmd 2.051, you'll get the 2.051 source.

Oh, of course. Total mind lapse, I forgot the source is included with the compiler. Compiling the source from the .zip still yields a broken dmd.exe. My version and the one from the .zip seem to differ in many small ways. The first difference is that in main(), the .zip version calls a function to get the address of errno, while my .exe accesses a variable directly. Some disassembly for clarity: === dmd.exe from dmd.2.051.zip === _TEXT:00402C27 loc_402C27: ; CODE XREF: sub_402360+8ADj _TEXT:00402C27 call sub_4F1314 _TEXT:00402C2C lea ecx, [ebp+var_88] _TEXT:00402C32 push 0Ah _TEXT:00402C34 mov dword ptr [eax], 0 _TEXT:00402C3A push ecx _TEXT:00402C3B mov edx, [ebp+var_88] _TEXT:00402C41 add edx, 7 _TEXT:00402C44 push edx _TEXT:00402C45 call sub_4F1340 _TEXT:00402C4A add esp, 0Ch _TEXT:00402C4D mov ecx, [ebp+var_88] _TEXT:00402C53 cmp byte ptr [ecx], 0 _TEXT:00402C56 mov esi, eax _TEXT:00402C58 jnz loc_402FA5 _TEXT:00402C5E call sub_4F1314 _TEXT:00402C63 cmp dword ptr [eax], 0 _TEXT:00402C66 jnz loc_402FA5 _TEXT:00402C6C cmp esi, 7FFFFFFFh _TEXT:00402C72 jg loc_402FA5 _TEXT:00402C78 push esi _TEXT:00402C79 call sub_464451 _TEXT:00402C7E add esp, 4 _TEXT:00402C81 jmp loc_4030E3 === dmd.exe compiled by me === _TEXT:00402C27 loc_402C27: ; CODE XREF: sub_402360+8ADj _TEXT:00402C27 push 0Ah _TEXT:00402C29 lea ecx, [ebp+var_88] _TEXT:00402C2F mov ds:dword_5376D3, 0 _TEXT:00402C39 push ecx _TEXT:00402C3A mov edx, [ebp+var_88] _TEXT:00402C40 add edx, 7 _TEXT:00402C43 push edx _TEXT:00402C44 call sub_4F0138 _TEXT:00402C49 add esp, 0Ch _TEXT:00402C4C mov ecx, [ebp+var_88] _TEXT:00402C52 cmp byte ptr [ecx], 0 _TEXT:00402C55 mov esi, eax _TEXT:00402C57 jnz loc_402FA1 _TEXT:00402C5D cmp ds:dword_5376D3, 0 _TEXT:00402C64 jnz loc_402FA1 _TEXT:00402C6A cmp esi, 7FFFFFFFh _TEXT:00402C70 jg loc_402FA1 _TEXT:00402C76 push esi _TEXT:00402C77 call sub_463E87 _TEXT:00402C7C add esp, 4 _TEXT:00402C7F jmp loc_4030DF Do we use a different version of the compiler or libc to compile DMD? I believe I use the latest version at http://ftp.digitalmars.com/dmc.zip . -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 30 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Mon, 31 Jan 2011 06:13:54 +0200, Walter Bright  
<newshound2 digitalmars.com> wrote:

 Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. My  
 version and the one from the .zip seem to differ in many small ways.  
 The first difference is that in main(), the .zip version calls a  
 function to get the address of errno, while my .exe accesses a variable  
 directly.

Check your dmc's errno.h. It should call a function.

It's declared as follows: #if defined(_MT) || defined(_DLL) || __cplusplus extern int * __CLIB _errno(void); #define errno (*_errno()) #else extern int __cdecl errno; #endif So, which of _MT or _DLL or __cplusplus should be defined on my machine but aren't? -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 31 2011
prev sibling next sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tue, 01 Feb 2011 00:30:27 +0200, Walter Bright  
<newshound2 digitalmars.com> wrote:

 Vladimir Panteleev wrote:
 On Mon, 31 Jan 2011 06:13:54 +0200, Walter Bright  
 <newshound2 digitalmars.com> wrote:

 Vladimir Panteleev wrote:
 Compiling the source from the .zip still yields a broken dmd.exe. My  
 version and the one from the .zip seem to differ in many small ways.  
 The first difference is that in main(), the .zip version calls a  
 function to get the address of errno, while my .exe accesses a  
 variable directly.

Check your dmc's errno.h. It should call a function.



Actually, it's declared in three files: errno.h, stdlib.h and stddef.h. mars.c uses only the last two.
 _MT and __cplusplus

Why should _MT be enabled? There is no -D_MT in win32.mak. Are we using different makefiles? root/async.c sets _MT explicitly, but the example at hand is from mars.c. If I add -D_MT to CFLAGS in the makefile, I still get a lot of differences. The first difference is now one in a function's prologue/epilogue - the binary from the .zip saves/restores the ECX register, while my binary doesn't. The functions are otherwise identical. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 31 2011
prev sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tue, 01 Feb 2011 05:30:44 +0200, Walter Bright  
<newshound2 digitalmars.com> wrote:

 Try compiling a small file, like hello world, with the -e -l flags, and  
 email me the resulting .lst file.

I found the problem. Both DMC and its header files were outdated. I don't know how I got to the conclusion that it was up-to-date. Sorry for wasting your time. -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Jan 31 2011