Bug 14074 – [REG2.067a] non-separate compilation fails, but separate compilation works

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-28T23:55:00Z
Last change time
2015-02-04T09:38:08Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
ketmar

Comments

Comment #0 by ketmar — 2015-01-28T23:55:41Z
steps to reproduce: git clone https://github.com/MrSmith33/cbor-d.git cd cbor-d git reset --hard 7fc1a49145b632674b071a525ca22c6010f451b7 cat >z00.d import std.stdio; import cbor; struct Inner { int[] array; string someText; } struct Test { ubyte b; short s; uint i; long l; float f; double d; ubyte[] arr; string str; Inner inner; void fun(){} // not encoded void* pointer; // not encoded int* numPointer; // not encoded } void main () { ubyte[1024] buffer; size_t encodedSize; Test test = Test(42, -120, 111111, -123456789, 0.1234, -0.987654, cast(ubyte[])[1,2,3,4,5,6,7,8], "It is a test string", Inner([1,2,3,4,5], "Test of inner struct")); encodedSize = encodeCborArray(buffer[], test); // ubyte[] and string types are slices of input ubyte[]. Test result = decodeCborSingle!Test(buffer[0..encodedSize]); // decodeCborSingleDup can be used to auto-dup those types. assert(test == result); { auto fo = File("z.bin", "w"); fo.rawWrite(buffer[0..encodedSize]); } } ^D dmd z00.d cbor.d z00.o: In function `cbor.putChecked!(ubyte[], ubyte).putChecked(ref ubyte[], const(ubyte))': cbor.d:(.text._D4cbor21__T10putCheckedTAhThZ10putCheckedFNaNbNiNfKAhxhZv+0xa): undefined reference to `std.range.primitives.put!(ubyte[], const(ubyte)).put(ref ubyte[], const(ubyte))' z00.o: In function `cbor.putChecked!(ubyte[], ubyte[]).putChecked(ref ubyte[], const(ubyte[]))': cbor.d:(.text._D4cbor22__T10putCheckedTAhTAhZ10putCheckedFNaNbNiNfKAhxAhZv+0xd): undefined reference to `std.range.primitives.put!(ubyte[], const(ubyte)[]).put(ref ubyte[], const(ubyte)[])' z00.o: In function `cbor.putChecked!(ubyte[], ubyte[]).putChecked(ref ubyte[], ref const(ubyte[]))': cbor.d:(.text._D4cbor22__T10putCheckedTAhTAhZ10putCheckedFNaNbNiNfKAhKxAhZv+0xf): undefined reference to `std.range.primitives.put!(ubyte[], const(ubyte)[]).put(ref ubyte[], const(ubyte)[])' collect2: error: ld returned 1 exit status yet this works ok: dmd -c cbor.d dmd z00.d cbor.o p.s. gdc with 2.066.1 backend is working ok for both cases.
Comment #1 by sinkuupump — 2015-02-01T03:53:49Z
This is introduced by pull: https://github.com/D-Programming-Language/dmd/pull/3948 I reduced into small source files: //////// cbor.d void encodeCbor(R, E)(R sink, E value) { encodeCborInt(sink); encodeCborArray(sink, value); static assert(false); } void encodeLongType(R)(R sink) { import primitives; put(sink); } void encodeCborInt(R)(R sink) { encodeLongType(sink); } void encodeCborArrayHead(R)(R sink, ulong arrayLength) { encodeLongType(sink); } void encodeCborArray(R, A)(R sink, A) { encodeCborArrayHead(sink, __traits(compiles, { encodeCbor(cast(ubyte[])null, A.tupleof[0].init); })); } //////// primitives.d void put(R)(R) { } //////// test.d import primitives; // necessary import cbor; struct Inner { } struct Test { Inner inner; } void main () { ubyte[] buffer; Test test ; encodeCborArray(buffer, test); } $ ls cbor.d primitives.d test.d $ dmd test.d cbor.d test.o: In function `pure nothrow @nogc @safe void cbor.encodeLongType!(ubyte[]).encodeLongType(ubyte[])': cbor.d:(.text.pure nothrow @nogc @safe void cbor.encodeLongType!(ubyte[]).encodeLongType(ubyte[])+0x1c): undefined reference to `pure nothrow @nogc @safe void primitives.put!(ubyte[]).put(ubyte[])' collect2: error: ld returned 1 exit status --- errorlevel 1 $ dmd -allinst test.d cbor.d && echo OK OK $ dmd -c cbor.d $ dmd test.d cbor.o && echo OK OK
Comment #2 by k.hara.pg — 2015-02-01T15:49:23Z
Comment #3 by ketmar — 2015-02-01T16:01:00Z
alas, with that PR i wasn't able to build neither rdmd, nor ddemangle or dustmite: In function `std.regex.internal.backtracking.BacktrackingMatcher!(true).BacktrackingMatcher!(char, std.regex.internal.ir.Input!(char).Input).BacktrackingMatcher.bwdMatcher(ref std.regex.internal.backtracking.BacktrackingMatcher!(true).BacktrackingMatcher!(char, std.regex.internal.ir.Input!(char).Input).BacktrackingMatcher, void[])': … (alot of text alot of text alot of text)
Comment #4 by k.hara.pg — 2015-02-02T17:09:03Z
(In reply to Ketmar Dark from comment #3) > alas, with that PR i wasn't able to build neither rdmd, nor ddemangle or > dustmite: > > In function > `std.regex.internal.backtracking.BacktrackingMatcher!(true). > BacktrackingMatcher!(char, > std.regex.internal.ir.Input!(char).Input).BacktrackingMatcher.bwdMatcher(ref > std.regex.internal.backtracking.BacktrackingMatcher!(true). > BacktrackingMatcher!(char, > std.regex.internal.ir.Input!(char).Input).BacktrackingMatcher, void[])': … > (alot of text alot of text alot of text) I updated PR to fix the build failure.
Comment #5 by ketmar — 2015-02-02T17:21:11Z
yes, it seems to work now. thank you.
Comment #6 by github-bugzilla — 2015-02-04T09:38:07Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/58163bb69e980cdc54cf3950296c370bddbbf4cc fix Issue 14074 - non-separate compilation fails, but separate compilation works https://github.com/D-Programming-Language/dmd/commit/f73fcd7d6dce1bb5cee1aed263ba470e0098590d Merge pull request #4369 from 9rnsr/fix14074 [REG2.067a] Issue 14074 - non-separate compilation fails, but separate compilation works