www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - using dub and -checkaction=context

reply Steven Schveighoffer <schveiguy gmail.com> writes:
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__dt
rMFNaNbNiZv]+0x5c): 
undefined reference to 
`_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf'
/home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/.dub/build/epoll-$DFLAGS-linux.posix-x86_64-dmd_2093-6D60905058E56B7C24E84CCDF9B29FD3/libvibe_core.
(sync_1456_5e95.o): 
In function 
`_D4vibe4core4sync__T22RecursiveTaskMutexImplVbi0ZQBd6unlockMFNeZ9__lambda1MFNbNfZv':
/home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/source/vibe/core/sync.d:(.text._D4vibe4core4sync__T22RecursiveTaskMutexImplVbi0ZQBd6unlockMFNeZ9__lambda1MFNbNfZv[_D4vibe4core4sync__T22RecursiveTaskMutexImplVbi0ZQBd6unlockMFNeZ9__lam
da1MFNbNfZv]+0xb7): 
undefined reference to 
`_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf'
/home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/.dub/build/epoll-$DFLAGS-linux.posix-x86_64-dmd_2093-6D60905058E56B7C24E84CCDF9B29FD3/libvibe_core.
(sync_145a_5e95.o): 
In function 
`_D4vibe4core4sync__T22RecursiveTaskMutexImplVbi1ZQBd6unlockMFNeZ9__lambda1MFNbNfZv':
/home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/source/vibe/core/sync.d:(.text._D4vibe4core4sync__T22RecursiveTaskMutexImplVbi1ZQBd6unlockMFNeZ9__lambda1MFNbNfZv[_D4vibe4core4sync__T22RecursiveTaskMutexImplVbi1ZQBd6unlockMFNeZ9__lam
da1MFNbNfZv]+0xb7): 
undefined reference to 
`_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf'
/home/steves/.dub/packages/vibe-core-1.10.1/vibe-core/.dub/build/epoll-$DFLAGS-linux.posix-x86_64-dmd_2093-6D60905058E56B7C24E84CCDF9B29FD3/libvibe_core.a(
ypecons_91_11ed.o): 
In function 
`_D3std8typecons__T10RefCountedTSQBe9container10binaryheap__T10BinaryHeapTSQCuQBq5array__T5ArrayTS4vibe4core4sync18LocalTaskSemaphore12ThreadWaiterZQCgS_DQCeQCcQCaQBy3ascFNfKQCzKQDdZbZQEt4DataVEQHjQHi24RefCountedAutoInitializei0ZQIc6__dtorMFNaNbNiZv':
/home/steves/.dvm/compilers/dmd-2.093.1/linux/bin/../../src/phobos/std/typecons.d:(.text._D3std8typecons__T10RefCountedTSQBe9container10binaryheap__T10BinaryHeapTSQCuQBq5array__T5ArrayTS4vibe4core4sync18LocalTaskSemaphore12ThreadWaiterZQCgS_DQCeQCcQCaQBy3ascFNfKQCzKQDdZbZQEt4DataVEQHjQHi24RefCountedAutoInitializei0ZQIc6__dtorMFNaNbNiZv[_D3std8typecons__T10RefCountedTSQBe9container10binaryheap__T10BinaryHeapTSQCuQBq5array__T5ArrayTS4vibe4core4sync18LocalTaskSemaphore12ThreadWaiterZQCgS_DQCeQCcQCaQBy3ascFNfKQCzKQDdZbZQEt4DataVEQHjQHi24RefCountedAutoInitializei0ZQIc6__dt
rMFNaNbNiZv]+0x5c): 
undefined reference to 
`_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf'

How am I supposed to do this? I tried setting DFLAGS and LDFLAGS and 
still linker errors. What am I doing wrong?

-Steve
Jan 17
parent reply Anonymouse <zorael gmail.com> writes:
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__dt
rMFNaNbNiZv]+0x5c): undefined reference to
`_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQBeFNaNbNiNfKxmxiZQBf'
https://issues.dlang.org/show_bug.cgi?id=19937 ? Slightly different error message though.
Jan 17
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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__dt
rMFNaNbNiZv]+0x5c): 
 undefined reference to 
 `_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQB
FNaNbNiNfKxmxiZQBf' 
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). -Steve
Jan 17
parent reply Mathias LANG <geod24 gmail.com> writes:
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__dt
rMFNaNbNiZv]+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). -Steve
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. 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. 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 ...
Jan 18
parent Steven Schveighoffer <schveiguy gmail.com> writes:
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__dt
rMFNaNbNiZv]+0x5c): 
 undefined reference to 
 `_D4core8internal7dassert__T14_d_assert_failVAyaa1_3eTmTiZQB
FNaNbNiNfKxmxiZQBf' 
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
Jan 18