Bug 8443 – [2.060 beta] Win32 linker bug with separate compilation

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-07-25T15:40:00Z
Last change time
2012-12-16T01:11:42Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-07-25T15:40:49Z
Compiling with -c on a module-by-module basis creates linking errors and a linker crash. Test-case for a Win32 machine: $ git clone https://github.com/AndrejMitrovic/WindowsAPI.git Open the WindowsAPI folder and paste this D script: module build; import std.array; import std.conv; import std.stdio; import std.parallelism; import std.file; import std.path; import std.process; import std.string; alias std.string.join join; void main() { string[] objFiles; string[] entries; foreach (string entry; dirEntries(r"win32", SpanMode.shallow)) entries ~= entry; // .array won't work.., to!string[] won't work.. foreach (string entry; parallel(entries, 1)) { string objFile = entry.stripExtension.setExtension(".obj"); objFiles ~= objFile; string cmd = format("dmd -c -version=Unicode -version=WindowsXP %s -of%s", entry, objFile); system(cmd); } system("echo void main() { } > test.d"); string cmd = format("dmd test.d -version=Unicode -version=WindowsXP %s", objFiles.join(" ")); system(cmd); } Run it: $ rdmd build.d This is what I get: Error 32: Data Outside Segment Bounds : _DATA win32\mmsystem.obj(mmsystem) Error 32: Data Outside Segment Bounds : _DATA win32\mmsystem.obj(mmsystem) Error 32: Data Outside Segment Bounds : _DATA win32\mmsystem.obj(mmsystem) Error 32: Data Outside Segment Bounds : _DATA win32\mmsystem.obj(mmsystem) Error 32: Data Outside Segment Bounds : _DATA and a crash: --------------------------- Unexpected OPTLINK Termination at EIP=00402C6C --------------------------- EAX=017C0000 EBX=004C22F8 ECX=00000004 EDX=0001FFFF ESI=010524DC EDI=00003FF8 EBP=0012FFF0 ESP=0012FF84 First=00402000 The script works fine with 2.059.
Comment #1 by bugzilla — 2012-07-25T15:49:31Z
What happens with this same code on linux or osx?
Comment #2 by andrej.mitrovich — 2012-07-25T16:30:26Z
(In reply to comment #1) > What happens with this same code on linux or osx? It can't be compiled on those, WindowsAPI is the Win32 bindings library.
Comment #3 by brocolis — 2012-07-27T15:33:21Z
2.060 beta - If I do an incremental build of the WindowsAPI (dmd -lib file1.obj file2.obj...) and link the resulting library with the following code, I get a 12,675KB executable. --- code --- import win32.commdlg; void main() { } class App { void MyFunc() { OPENFILENAMEW ofn; } } --- code --- If I do one-step build of the WindowsAPI, I get a 153KB executable.
Comment #4 by brocolis — 2012-08-05T11:25:08Z
This appears to be fixed in git.
Comment #5 by andrej.mitrovich — 2012-12-14T09:53:59Z
(In reply to comment #4) > This appears to be fixed in git. Yeah it seems so, but I would really like to know which commit/pull fixed it and what exactly was wrong with the codegen. It seems it was a DMD issue because the Unilink linker also complained about segment size exceeding maximum allowable size. It doesn't complain when using git-head, and Optlink doesn't crash either.
Comment #6 by bugzilla — 2012-12-16T01:11:42Z
I compile it with head, it compiles successfully and produces a 347,676 byte executable.