remaining changes to pass semantic checks of druntime
text/plain
17262
Comments
Comment #0 by braddr — 2010-11-23T22:17:28Z
Created attachment 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.
Comment #1 by braddr — 2010-11-23T23:15:13Z
Ok, for #2, I think the right answer is to change _d_arrayappendcT to this:
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.
Comment #2 by braddr — 2010-11-24T01:35:00Z
ok, debugging #3. There's actually a couple of different assert locations, 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.
Comment #3 by braddr — 2010-11-24T02:32:54Z
for #3, call cleanup code in cod1.c funccall():
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?
Comment #4 by braddr — 2010-11-25T15:04:41Z
I'm splitting #3 into a standalone bug report. dmd-1.x exhibits the same problem and it's unrelated to druntime at all. New bug 5275.
Created attachment 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.
Comment #7 by braddr — 2010-12-08T00:33:38Z
All of these changes have been checked in. This doesn't mean that it work, just that it builds now. :)