www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8443] New: [2.060 beta] Win32 linker bug with separate compilation

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 25 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8443


Walter Bright <bugzilla digitalmars.com> changed:

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



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: -------
Jul 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8443




16:30:26 PDT ---

 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: -------
Jul 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8443


run3 myopera.com changed:

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



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: -------
Jul 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8443




This appears to be fixed in git.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 05 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8443




09:53:59 PST ---

 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: -------
Dec 14 2012
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 16 2012