www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5264] New: x86_64 changes for druntime 2

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264

           Summary: x86_64 changes for druntime 2
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: braddr puremagic.com



---
Created an attachment (id=830)
most of the changes to get druntime 2 to build with dmd -m64

I spent a couple hours today working on getting druntime 2 to build with the
x86_64 dmd compiler.  It's not 100% so far, but almost there.

What's broken:

1) lifetime.d has 4 va_arg calls commented out.  The compiler croaks with:

src/core/stdc/stdarg.d(229): Error: static assert  "not a valid argument type
for va_arg"
src/rt/lifetime.d(814):        instantiated from here: va_arg!(ulong)

2) lifetime.d _d_arrayappendcT needs to be altered to work with varargs
properly.  The 64 bit support is fragile/hacky/whatever and I haven't pieced
together how this code evolved between d1 and d2's runtimes.

3) lifetime.d _d_arrayshrinkfit() crashes the backend of the compiler:

function  _d_arrayshrinkfit
cod2.c:1769:  assert(stackpush == stackpushsave) // 0xfffffffc == 0

Normally I'd create 3 bugs since there's 3 different issues, but I don't think
that'd be useful here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 23 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|sean invisibleduck.org      |braddr puremagic.com



---


extern (C) void[] _d_arrayappendcT(TypeInfo ti, Array *x, ...)
{
    version(X86)
    {  
        byte *argp = cast(byte*)(&ti + 2);
        return _d_arrayappendT(ti, x, argp[0..1]);
    }
    else version(X86_64)
    {  
        va_list ap;
        va_start(ap, __va_argsave);
        byte[] argp;
        va_arg(ap, ti.next, argp);
        return _d_arrayappendT(ti, x, argp);
    }
    else
        static assert(false, "unknown version");
}

Builds at least, but can't test it yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264




---

though I suspect they're all related.  If the fix for this reduction doesn't
solve all of them, I'll re-reduce the next one.

=========
module hrm;

struct BlkInfo { size_t size; }

extern (C) BlkInfo gc_qalloc(size_t sz, uint ba);

void __setArrayAllocLength(ref BlkInfo info)
{
    if (info.size) {}
}

extern (C) void foo()
{
    BlkInfo info = gc_qalloc(0, 0);
    __setArrayAllocLength(info);
}
======

$ ../dmd-trunk/src/dmd -c -m64 hrm.d
Internal error: backend/cod1.c 2554

Building in 32 bit mode (without -m64) works just fine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264




---


2936         if (tym1 == TYhfunc)
2937         {   // Hidden parameter is popped off by the callee
2938             c = genadjesp(c, -4);
2939             stackpush -= 4;

This code isn't aware of the 32 vs 64 bit calling convention differences yet?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264




---

problem and it's unrelated to druntime at all.  New bug 5275.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264




---

change sets:

http://www.dsource.org/projects/dmd/changeset/717

Walter's merging those into dmd2 soon.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 28 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------

           obsolete|                            |



---
Created an attachment (id=835)
remaining changes to pass semantic checks of druntime

(actually not all, see also bug 5263 for intrinsic cleanup)

This time I ran the druntime and phobos unittests on 32 bit.  They pass.  The
64 bit tests can't be run yet as there's still dmd codgen bugs while building
druntime.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 02 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5264


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



---
All of these changes have been checked in.  This doesn't mean that it work,
just that it builds now. :)

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