D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13172 - optimize and rawread cause symbol undefined errors
Summary: optimize and rawread cause symbol undefined errors
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P1 normal
Assignee: No Owner
URL:
Keywords:
: 13898 14043 14202 (view as issue list)
Depends on:
Blocks:
 
Reported: 2014-07-20 22:05 UTC by maarten
Modified: 2017-10-25 03:26 UTC (History)
10 users (show)

See Also:


Attachments
example 1: OK (86 bytes, text/plain)
2014-07-28 14:16 UTC, Ivan Kazmenko
Details
example 2: fails with -inline (87 bytes, text/plain)
2014-07-28 14:16 UTC, Ivan Kazmenko
Details

Note You need to log in before you can comment on or make changes to this issue.
Description maarten 2014-07-20 22:05:55 UTC
when compiling with -O -release -inline -noboundscheck, the following program: 

import std.stdio;  
uint[] meuh(){ 
File f; 
uint[] vfield=new uint[](3);
 return f.rawRead(vfield); 
}  
void main(){}

gives the following error :
 Error 42: Symbol Undefined _D3std9exception133__T12errnoEnforceTbVAyaa50_433a5c
445c646d64325c77696e646f77735c62696e5c2e2e5c1079E2AF018CEE885E4194B2927ACD6F
--- errorlevel 1

This also failes to compile with optimization flags on ldmd2 . It is possible to use '-allinst' to make it compile on dmd.
Not that this does compile without optimization flags, and it does compile on linux
Comment 1 maarten 2014-07-22 16:57:03 UTC
it's possible to remove the linker errors by adding std/exception.d to the to-compile file list but then the program immediatly runs out of memory, even though it doesn't when you don't optimize it.
Comment 2 maarten 2014-07-22 18:48:36 UTC
commenting out the line with errnoEnforce in std/stdio.d fixes my problems (but probably breaks a few things). It's not worthy of a patch but it's good enough for me.
Comment 3 jyxent 2014-07-24 17:39:28 UTC
I get the same issue on linux with dmd git head.

The -inline flag causes the issue for me.  I can add -O -release and -noboundscheck without getting the linker issue.
Comment 4 Ivan Kazmenko 2014-07-28 14:15:42 UTC
I got that bug, too.

I have a small family of examples here.

-----example1.d:OK-----
import std.stdio;
void main () {
    ubyte [256] buf;
    stdin.rawRead (buf);
}
-----

-----example2.d:Fails with -inline-----
import std.stdio;
void main () {
    ushort [256] buf; // same with uint
    stdin.rawRead (buf);
}
-----

Checked with DMD 2.064.2, DMD 2.065.0 and DMD 2.066-0-b6, the results are roughly the same.

Example 1 is OK.

In example 2, certain optimizations lead to linker errors.  To compile successfully, just run "dmd <file>.d". For versions 2.064 and 2.066, just adding "-inline" causes a linker error. For 2.065, the error requires the full "-release -inline -noboundscheck" to be reproduced locally.

-----With "-m32" (OPTLINK):-----
OPTLINK (R) for Win32  Release 8.00.15
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
example2.obj(example2) 
 Error 42: Symbol Undefined _D3std9exception140__T12errnoEnforceTbVAyaa53_433a5c546f6f6c735c646d645c77696e646f77735c62696e5cE611F934D2BE6B410FCD651C953DEFB1
--- errorlevel 1
-----

-----With "-m64" (MS VS 12.0 linker):-----
example2.obj : error LNK2019: unresolved external symbol _D3std9exception140__T12errnoEnforceTbVAyaa53_433a5c546f6f6c735c646d645c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi717Z12errnoEnforceFNfbLAyaZb referenced in function _D3std5stdio4File14__T7rawReadTtZ7rawReadMFAtZAt
example2.exe : fatal error LNK1120: 1 unresolved externals
--- errorlevel 1120
-----
Comment 5 Ivan Kazmenko 2014-07-28 14:16:27 UTC
Created attachment 1372 [details]
example 1: OK
Comment 6 Ivan Kazmenko 2014-07-28 14:16:51 UTC
Created attachment 1373 [details]
example 2: fails with -inline
Comment 7 Aleksi Sapon 2014-12-27 00:37:53 UTC
*** Issue 13898 has been marked as a duplicate of this issue. ***
Comment 8 Aleksi Sapon 2015-01-28 20:01:33 UTC
*** Issue 14043 has been marked as a duplicate of this issue. ***
Comment 9 Tomer Filiba (weka) 2015-02-10 11:14:03 UTC
Any news on this one? I think I'm seeing something similar in my code, but it's too much code to pin-point an excerpt and post here.
Comment 10 Ketmar Dark 2015-02-10 12:53:53 UTC
can't confirm on GNU/Linux x86, dmd git head, commit b9c8ded6
Comment 11 Ketmar Dark 2015-02-10 12:54:29 UTC
ah… i missed "hardware" section for the bug. sorry for the noise.
Comment 12 Tomer Filiba (weka) 2015-02-10 12:56:46 UTC
Ketmar: we get this on linux too. 
Specifically, see https://issues.dlang.org/show_bug.cgi?id=14043
Comment 13 Ketmar Dark 2015-02-10 12:58:54 UTC
yes, but this seems to be x86_64 issue, and i checked it on x86. so i confirmed the thing that is not needed to be confirmed. ;-)
Comment 14 Justin Whear 2015-02-19 22:20:03 UTC
*** Issue 14202 has been marked as a duplicate of this issue. ***
Comment 15 briancschott 2015-02-20 22:13:44 UTC
I'm not able to reproduce this with 2.067.0-b2.
Comment 16 joeyemmons 2015-02-22 00:30:14 UTC
(In reply to briancschott from comment #15)
> I'm not able to reproduce this with 2.067.0-b2.

Had the same bug and switching to 2.067.0-b2 also fixed it. 
See http://forum.dlang.org/thread/vuyznzmdhuxsefeepegu@forum.dlang.org
Comment 17 Walter Bright 2017-10-25 03:26:10 UTC
(In reply to joeyemmons from comment #16)
> (In reply to briancschott from comment #15)
> > I'm not able to reproduce this with 2.067.0-b2.
> 
> Had the same bug and switching to 2.067.0-b2 also fixed it. 
> See http://forum.dlang.org/thread/vuyznzmdhuxsefeepegu@forum.dlang.org

I'll mark it as WORKSFORME then.