D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11069 - DMD (github HEAD) Linker Regression
Summary: DMD (github HEAD) Linker Regression
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P2 regression
Assignee: No Owner
URL:
Keywords: link-failure, pull
Depends on:
Blocks:
 
Reported: 2013-09-19 04:12 UTC by Puneet Goel
Modified: 2013-09-23 11:56 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Puneet Goel 2013-09-19 04:12:51 UTC
The following reduced code example fails to link. It seems to be due to DMD checkin 12bb9afb753ad2f2aef65550b960357c63854cbc -- fix Issue 10441 - Static libraries too big. Compiles fine if I try with one version before that.

On my Linux x64 box I get:

$ rdmd test.d
/tmp/.rdmd-1000/rdmd-test.d-C130B18713BE4647AF6BF8F764A06FDD/objs/test.o: In function `_D3std9container32__T10BinaryHeapTAS4test3Bar3FooZ10BinaryHeap3popMFAS4test3Bar3FooZv':
__entrypoint.d:(.text._D3std9container32__T10BinaryHeapTAS4test3Bar3FooZ10BinaryHeap3popMFAS4test3Bar3FooZv+0x5c): undefined reference to `_D3std5array25__T5emptyTS4test3Bar3FooZ5emptyFNaNbNdNfxAS4test3Bar3FooZb'


// test.d Reduced code example:

class Bar {
  import std.container: BinaryHeap;
  BinaryHeap!(Foo[]) Heap;
  struct Foo {
    int opCmp(Foo ) {
      return 1;
    }
  }
}

void main() {}
Comment 2 Temtaime 2013-09-22 04:11:31 UTC
Kenji, it's not a full solution. 
I've make test case from my project.
It's too strange test case, but as it is.

A.d:
import C;
import D;

void foo() {
	Vector2 rsm;
	readWriteVariable(rsm);
}

void main() {
}

B.d:
import D;

import std.algorithm;


void bar() {
	Vector2[] tc;
	sort(tc);
}

C.d:
import std.traits;

void readWriteVariable(T)(ref T data) {

	foreach(it; __traits(allMembers, T))
			enum vValid = mixin(`is(FunctionTypeOf!(T.` ~ it ~ `) == function)`);

}

D.d:
struct Matrix(T, uint _M) {
	int opCmp()(auto ref in Matrix b) const {
		return 0;
	}

	pure auto opDispatch(string s)() {
		enum L = s.length;
		Matrix!(T, L) ret;
		return ret;
	}

	pure Matrix normalized() {
		return Matrix();
	}
}

alias Matrix!(float, 2) Vector2;


Problem exists only if files compiled into single objs and then linked together.

dmd A -c
dmd b -c
dmd c -c
dmd d -c
dmd a.obj b.obj c.obj d.obj

 Error 42: Symbol Undefined _D1D16__T6MatrixTfVi2Z6Matrix8__xopCmpFKxS1D16__T6Ma
trixTfVi2Z6MatrixKxS1D16__T6MatrixTfVi2Z6MatrixZi
b.obj(b)
 Error 42: Symbol Undefined _D1D16__T6MatrixTfVk8Z6Matrix8__xopCmpFKxS1D16__T6Ma
trixTfVk8Z6MatrixKxS1D16__T6MatrixTfVk8Z6MatrixZi
b.obj(b)
 Error 42: Symbol Undefined _D1D16__T6MatrixTfVk6Z6Matrix8__xopCmpFKxS1D16__T6Ma
trixTfVk6Z6MatrixKxS1D16__T6MatrixTfVk6Z6MatrixZi
b.obj(b)
 Error 42: Symbol Undefined _D1D16__T6MatrixTfVk9Z6Matrix8__xopCmpFKxS1D16__T6Ma
trixTfVk9Z6MatrixKxS1D16__T6MatrixTfVk9Z6MatrixZi


If something is removed from test case, then linking is ok.
Comment 3 Kenji Hara 2013-09-22 08:03:50 UTC
(In reply to comment #2)
>  Error 42: Symbol Undefined
> _D1D16__T6MatrixTfVi2Z6Matrix8__xopCmpFKxS1D16__T6Ma
> trixTfVi2Z6MatrixKxS1D16__T6MatrixTfVi2Z6MatrixZi
> b.obj(b)
>  Error 42: Symbol Undefined
> _D1D16__T6MatrixTfVk8Z6Matrix8__xopCmpFKxS1D16__T6Ma
> trixTfVk8Z6MatrixKxS1D16__T6MatrixTfVk8Z6MatrixZi
> b.obj(b)
>  Error 42: Symbol Undefined
> _D1D16__T6MatrixTfVk6Z6Matrix8__xopCmpFKxS1D16__T6Ma
> trixTfVk6Z6MatrixKxS1D16__T6MatrixTfVk6Z6MatrixZi
> b.obj(b)
>  Error 42: Symbol Undefined
> _D1D16__T6MatrixTfVk9Z6Matrix8__xopCmpFKxS1D16__T6Ma
> trixTfVk9Z6MatrixKxS1D16__T6MatrixTfVk9Z6MatrixZi

OK, I confirmed the issue. And updated the PR to fix it.
Comment 4 github-bugzilla 2013-09-23 11:55:54 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c2ae0b2807c1863ef6653668478ae778fe4ff88e
fix Issue 11069 - DMD (github HEAD) Linker Regression

https://github.com/D-Programming-Language/dmd/commit/3e8460657b82b4ff38ece6fabc7e4a3015717529
Merge pull request #2577 from 9rnsr/fix11069

[REG2.064a] Issue 11069 - DMD (github HEAD) Linker Regression