Thread overview
dub ldc error _d_array_slice_copy
Feb 18, 2019
SrMordred
Feb 18, 2019
SrMordred
Feb 18, 2019
SrMordred
Feb 18, 2019
kinke
Feb 19, 2019
SrMordred
February 18, 2019
On ubuntu:

void test(size_t l)
{
    char* a;
    a[0 .. l] = a[0 .. l];	
}
extern(C) void main(){
	test(0);
}

ldc2 source/app.d //compiles

dub --compiler=ldc2 //app.d:4: error: undefined reference to '_d_array_slice_copy'



February 18, 2019
oh, and:
DUB version 1.13.0, built on Feb 17 2019

LDC - the LLVM D compiler (1.14.0):
  based on DMD v2.084.1 and LLVM 7.0.1

February 18, 2019
On Monday, 18 February 2019 at 19:14:42 UTC, SrMordred wrote:
> oh, and:
> DUB version 1.13.0, built on Feb 17 2019
>
> LDC - the LLVM D compiler (1.14.0):
>   based on DMD v2.084.1 and LLVM 7.0.1

Sorry, both give the same error, the problem is related to -betterC flag (which i forgot to add on first compile example), but stil..
February 18, 2019
On Monday, 18 February 2019 at 19:10:50 UTC, SrMordred wrote:
> dub --compiler=ldc2 //app.d:4: error: undefined reference to '_d_array_slice_copy'

Dub has nothing to do with it, it's the -betterC flag, and LDC expecting that druntime function to be available for slice copies. Quick workaround: add a manual version (here without any checks) somewhere in your code:

extern(C) void _d_array_slice_copy(void* dst, size_t dstlen, void* src, size_t srclen, size_t elemsz)
{
        import ldc.intrinsics : llvm_memcpy;
        llvm_memcpy!size_t(dst, src, dstlen * elemsz, 0);
}
February 19, 2019
On Monday, 18 February 2019 at 23:40:20 UTC, kinke wrote:
> On Monday, 18 February 2019 at 19:10:50 UTC, SrMordred wrote:
>> dub --compiler=ldc2 //app.d:4: error: undefined reference to '_d_array_slice_copy'
>
> Dub has nothing to do with it, it's the -betterC flag, and LDC expecting that druntime function to be available for slice copies. Quick workaround: add a manual version (here without any checks) somewhere in your code:
>
> extern(C) void _d_array_slice_copy(void* dst, size_t dstlen, void* src, size_t srclen, size_t elemsz)
> {
>         import ldc.intrinsics : llvm_memcpy;
>         llvm_memcpy!size_t(dst, src, dstlen * elemsz, 0);
> }

Thanks, I discovered this workaround too :)

But I dont get it:
-betterC aren't supoused to be D without any druntime?
Why it is searching for this function?