now I need -allinst when dmd compiles the unittest

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 5 03:36:04 UTC 2023


On Friday, 1 December 2023 at 22:00:52 UTC, kdevel wrote:
> If I not use -allinst the linker complains when using the 
> current msgpack-d v1.0.5, e.g.
>
> [...]msgpack-d/src/msgpack/package.d:203: undefined reference 
> to `pure nothrow @nogc @safe immutable(char)[] 
> core.internal.dassert._d_assert_fail!(int)._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), scope ref const(int), scope ref const(int))'
>
> [...]msgpack-d/src/msgpack/packer.d:1326: undefined reference 
> to `pure nothrow @nogc @safe immutable(char)[] 
> core.internal.dassert._d_assert_fail!(const(int))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), scope ref const(int), scope const(int))'
>
> [...]/msgpack-d/src/msgpack/unpacker.d:1505: undefined 
> reference to `pure nothrow @nogc @safe immutable(char)[] 
> core.internal.dassert._d_assert_fail!(int)._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), scope ref const(int), scope ref const(int))'

Are you using -checkaction=context? I have discovered that this 
happens if you build with -checkaction=context, but druntime has 
not been built with it, or you are using betterC.

What happens is that an assert failure will trigger a call to a 
druntime function, and the compiler thinks that function is 
already instantiated in druntime, so it skips emitting the 
function, and expects druntime to be linked.

I'm unsure whether druntime has the appropriate checkaction 
functions built by default, but definitely if you use betterC it 
won't be linked.

For reference:

https://issues.dlang.org/show_bug.cgi?id=22374
https://issues.dlang.org/show_bug.cgi?id=22902
https://issues.dlang.org/show_bug.cgi?id=19937

You even reported one of these...

-Steve


More information about the Digitalmars-d-learn mailing list