Comment #0 by timothee.cour2 — 2015-07-20T07:39:39Z
Reduced use case:
https://github.com/timotheecour/dsnippet/tree/master/bug_ld_GOT_reloc
dmd -of/tmp/fun3.o -c fun3.d && dmd -of/tmp/z01 /tmp/fun3.o fun2.d
ld: GOT load reloc does not point to a movq instruction in '_D4fun34fun4FZv' from /tmp/fun3.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
fun2:
import fun3;
void main(){
fun4;
}
fun3:
void fun0()
{
}
alias Fun = void function(); //same with delegate()
void fun4()
{
Fun[TypeInfo] funs;
funs[typeid(int)] = &fun0; //same with s/&fun0/(){}/
}
NOTE:
not sure whether b/7354 is related; it's very old but this one is a regression.
Comment #3 by timothee.cour2 — 2015-07-21T09:36:06Z
(In reply to Timothee Cour from comment #2)
> (In reply to Martin Nowak from comment #1)
> > Regression in which dmd version?
> > Can you please bisect dmd using Digger
> > (https://github.com/CyberShadow/Digger)?
>
> I had written it in that link
> https://github.com/timotheecour/dsnippet/tree/master/bug_ld_GOT_reloc :
> `
> dmd --version
> DMD64 D Compiler v2.068-devel-80a326e
> NOTE: works fine with dmd v2.067.1
> `
ok here's a more fine grained version showing https://github.com/D-Programming-Language/dmd/pull/4654 is the culprit:
digger: 2c5809577aafd8c6199dc04ca4ea874c4bafae9b is the first bad commit
commit 2c5809577aafd8c6199dc04ca4ea874c4bafae9b
Author: Hara Kenji <[email protected]>
Date: Mon May 18 23:37:54 2015 +0900
dmd: Merge pull request #4654 from yebblies/typeid
https://github.com/D-Programming-Language/dmd/pull/4654
Resolve TypeInfo variables after semantic
diff --git a/dmd b/dmd
index a7d1edb..7fa9cd9 160000
--- a/dmd
+++ b/dmd
@@ -1 +1 @@
-Subproject commit a7d1edb3c17282994c53fdc797dc3d15f3919d68
+Subproject commit 7fa9cd9de5d24bede6cb5b4f5d4840a2b5140b7c
digger: Bisection completed successfully.
Thanks for suggesting using Digger!
Comment #4 by k.hara.pg — 2015-07-21T13:37:48Z
(In reply to Timothee Cour from comment #3)
> ok here's a more fine grained version showing
> https://github.com/D-Programming-Language/dmd/pull/4654 is the culprit:
I don't have Mac OS X environment, so I cannot directly test the reduced case.
But I found a difference in the glue-layer output introduced by the PR.
(In reply to Timothee Cour from comment #0)
> fun3:
> void fun0()
> {
> }
>
> alias Fun = void function(); //same with delegate()
>
> void fun4()
> {
> Fun[TypeInfo] funs;
> funs[typeid(int)] = &fun0; //same with s/&fun0/(){}/
> }
If you replace the `typeid(int)` with `null`, will the failure disappear?
If so, may following patch fix fix the issue?
---
src/e2ir.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/e2ir.c b/src/e2ir.c
index 863bd14..88d2a63 100644
--- a/src/e2ir.c
+++ b/src/e2ir.c
@@ -1175,6 +1175,7 @@ elem *toElem(Expression *e, IRState *irs)
if (Type *t = isType(e->obj))
{
result = getTypeInfo(t, irs);
+ result = el_bin(OPadd, result->Ety, result, el_long(TYsize_t, t->vtinfo->offset));
return;
}
if (Expression *ex = isExpression(e->obj))
--
Comment #5 by timothee.cour2 — 2015-07-22T04:01:34Z
>> If you replace the `typeid(int)` with `null`, will the failure disappear?
yes
>> If so, may following patch fix fix the issue?
it does.
Here's the corresponding pull request:
https://github.com/D-Programming-Language/dmd/pull/4827
Comment #6 by k.hara.pg — 2015-07-22T13:12:42Z
(In reply to Timothee Cour from comment #5)
> >> If you replace the `typeid(int)` with `null`, will the failure disappear?
>
> yes
>
> >> If so, may following patch fix fix the issue?
>
> it does.
Thanks for the test.
I also confirmed the issue on auto-tester with a test case, then applied my patch.
https://github.com/D-Programming-Language/dmd/pull/4828