Thread overview
Link error triggered by `dub test` but not by `dub build --unittest`
Jun 16, 2020
Per Nordlöw
Jun 17, 2020
Per Nordlöw
Jun 17, 2020
Per Nordlöw
Jun 17, 2020
Per Nordlöw
June 16, 2020
Inside

https://github.com/nordlow/phobos-next/

doing

   dub build --compiler=dmd --build=unittest

works but

   dub test --compiler=dmd

fails as

Generating test runner configuration 'phobos-next-test-library' for 'library' (library).
Performing "unittest" build using /usr/bin/dmd for x86_64.
phobos-next ~master: building configuration "phobos-next-test-library"...
Linking...
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D268TypeInfo_S4core8internal8lifetime__T10emplaceRefTS3nxt13dynamic_array__T12DynamicArrayTSQBm22sso_hashmap_or_hashset__T15SSOHashMapOrSetTkTCQDlQBz20__unittest_L1781_C15FNaNeZ1VVnnTSQFa7digestx3fnv__T3FNVVmi64Vbi1ZQoVki1Vki2Vki1ZQEf1TVQCfnTkZQGmTQHnTG2QGhZQIkFKQIcKQpZ1S6__initZ: error: undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D270TypeInfo_S4core8internal8lifetime__T10emplaceRefTS3nxt13dynamic_array__T12DynamicArrayTSQBm22sso_hashmap_or_hashset__T15SSOHashMapOrSetTkTCQDlQBz20__unittest_L1837_C14FNaNbNfZ1VVnnTSQFc7digestx3fnv__T3FNVVmi64Vbi1ZQoVki1Vki2Vki1ZQEh1TVQCfnTkZQGoTQHpTG2QGjZQImFKQIeKQpZ1S6__initZ: error: undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D124TypeInfo_S3std8typecons__T5TupleTSQy5range__T11SortedRangeTAiVAyaa5_61203c2062VEQCsQBv18SortedRangeOptionsi0ZQCmTQDcTQDgZQDr6__initZ: error: undefined reference to '_D6object7_xopCmpFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D109TypeInfo_S3std8typecons__T5TupleTiTS3nxt12algorithm_ex__T17forwardDifferenceTAiZQxFQgZ17ForwardDifferenceZQDc6__initZ: error: undefined reference to '_D6object7_xopCmpFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D49TypeInfo_S3std8typecons__T5TupleTC8TypeInfoTPvZQv6__initZ: error: undefined reference to '_D6object7_xopCmpFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D52TypeInfo_S3std8typecons__T5TupleTC8TypeInfoTPG32hZQy6__initZ: error: undefined reference to '_D6object7_xopCmpFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D3nxt5bound22BoundOverflowException6__vtblZ: error: undefined reference to '_D6object9Throwable8toStringMxFMDFMxAaZvZv'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D3nxt6cyclic16CyclicRangeError6__vtblZ: error: undefined reference to '_D6object9Throwable8toStringMxFMDFMxAaZvZv'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D46TypeInfo_S3nxt6cyclic__T11CyclicArrayTiVmi0ZQu6__initZ: error: undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D70TypeInfo_S3nxt6cyclic__T11CyclicArrayTSQBdQBc13structBug5920Vmi256ZQBr6__initZ: error: undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'
.dub/build/phobos-next-test-library-unittest-linux.posix-x86_64-dmd_2092-4171FC1A47BBEE27E965310B42F6CCF0/phobos-next-test-library.o:src/nxt/zio.d:_D3nxt7variant23LightAlgebraicException6__vtblZ: error: undefined reference to '_D6object9Throwable8toStringMxFMDFMxAaZvZv'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
/usr/bin/dmd failed with exit code 1.

All the linker errors originate from zio.d but zio.d has its unittests disabled so how come this fails to link?

And how come

    dub build --unittest

passes

when

    dub test

doesn't?

I'm sitting on Ubuntu 20.04 x64.
June 17, 2020
On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote:
> All the linker errors originate from zio.d but zio.d has its unittests disabled so how come this fails to link?


zio.d is not the source of the problem. Something else is.

The common denominator seems to be that the builtins xopEqual and xopCmp aren't defined upon linking. These seem to be generated by dmd. Can anybody explain what's going on here?
June 17, 2020
On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote:
> when
>
>     dub test
>
> doesn't?

I'm trying to reduce it through

    dustmite phobos-next "dub test 2>&1 | grep -F '_D6object10_xopEqualsFMxPvMxQeZb'"

Is this the best way to use dustmite in this case?
June 17, 2020
On Wednesday, 17 June 2020 at 12:12:24 UTC, Per Nordlöw wrote:
> On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote:
>> when
>>
>>     dub test
>>
>> doesn't?
>
> I'm trying to reduce it through
>
>     dustmite phobos-next "dub test 2>&1 | grep -F '_D6object10_xopEqualsFMxPvMxQeZb'"
>
> Is this the best way to use dustmite in this case?

Was reduced to rational.d with content


module nxt.rational;

Rational!(I1) rational(I1, I2)(I1 , I2)
{
    return typeof(return)();
}

struct Rational(Int)
{
    bool opEquals(Rhs)(Rhs _) {}
}

@nogc unittest
{
    auto _ = rational(1, 2);
}


When I remove

    bool opEquals(Rhs)(Rhs _) {}

error goes away. Seems like a bug to me.