using dub and -checkaction=context

Steven Schveighoffer schveiguy at gmail.com
Mon Jan 18 14:36:42 UTC 2021


On 1/18/21 7:48 AM, Mathias LANG wrote:
> On Sunday, 17 January 2021 at 20:42:06 UTC, Steven Schveighoffer wrote:
>> On 1/17/21 2:27 PM, Anonymouse wrote:
>>> On Sunday, 17 January 2021 at 15:41:45 UTC, Steven Schveighoffer wrote:
>>>> I'm trying to run unittests using `dub test`, and I wanted to use 
>>>> the new -checkaction=context feature to avoid having to instrument 
>>>> my unittests to print out the string comparison failure that's 
>>>> happening.
>>>>
>>>> But I tried adding this to my dub.sdl file:
>>>>
>>>> dflags "-checkaction=context" platform="dmd"
>>>>
>>>> But now I get linker errors:
>>>>
>>>> /home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/source/vibe/appmain.d:(.text._D3std8typecons__T10RefCountedTSQBe9container5array__T5ArrayTS4vibe4core4sync18LocalTaskSemaphore12ThreadWaiterZQCg7PayloadVEQEtQEs24RefCountedAutoInitializei0ZQFm6__dtorMFNaNbNiZv[_D3std8typecons__T10RefCountedTSQBe9container5array__T5ArrayTS4vibe4core4sync18LocalTaskSemaphore12ThreadWaiterZQCg7PayloadVEQEtQEs24RefCountedAutoInitializei0ZQFm6__dtorMFNaNbNiZv]+0x5c): 
>>>> undefined reference to 
>>>> `_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf' 
>>>>
>>>>
>>>
>>> https://issues.dlang.org/show_bug.cgi?id=19937 ? Slightly different 
>>> error message though.
>>
>> Yeah, that's probably it. Hm... this feature isn't very usable if I 
>> can't use it with dub. And the bug report you linked to also has an 
>> example that fails with straight dmd (even without unittests).
>>
> 
> Yeah, it's currently not usable, because DMD thinks the template is 
> already instantiated in Phobos / druntime. I tried to work around it in 
> my projects and it didn't work out.

OK, good to know. I didn't spend too much time on it.

> I want to enable it by default but there's 2 issues blocking it ATM (see 
> https://github.com/dlang/dmd/pull/11925). Once that PR is green, we can 
> enable it when compiling druntime / Phobos and your linker errors will 
> disappear.
Looking forward to that!

> 
> Also, dub-wise, you can't really use `-preview` before the latest 
> release. That's why we added 
> https://github.com/dlang/dub/commit/cd9b30e04813108c05abf97d97a42daf466eabdb 
> ...

Yeah, this isn't exactly a preview switch, but the dub feature is 
definitely necessary.

Another thought -- can the frontend specially treat these assert 
templates with -allinst even when that switch isn't present? Would that 
solve the problem?

-Steve


More information about the Digitalmars-d-learn mailing list