Thread overview
[Issue 8443] New: [2.060 beta] Win32 linker bug with separate compilation
Jul 25, 2012
Andrej Mitrovic
Jul 25, 2012
Walter Bright
Jul 25, 2012
Andrej Mitrovic
Jul 27, 2012
run3@myopera.com
Aug 05, 2012
run3@myopera.com
Dec 14, 2012
Andrej Mitrovic
Dec 16, 2012
Walter Bright
July 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443

           Summary: [2.060 beta] Win32 linker bug with separate
                    compilation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-07-25 15:40:49 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2012-07-25 15:49:31 PDT ---
What happens with this same code on linux or osx?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-07-25 16:30:26 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443


run3@myopera.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |run3@myopera.com


--- Comment #3 from run3@myopera.com 2012-07-27 15:33:21 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443



--- Comment #4 from run3@myopera.com 2012-08-05 11:25:08 PDT ---
This appears to be fixed in git.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443



--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-14 09:53:59 PST ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8443


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Platform|All                         |x86
         Resolution|                            |WORKSFORME
         OS/Version|All                         |Windows


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2012-12-16 01:11:42 PST ---
I compile it with head, it compiles successfully and produces a 347,676 byte executable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------