Thread overview
LDC: Where is this supposed to link to?
Jun 12, 2018
Dukc
Jun 12, 2018
Adam D. Ruppe
Jun 12, 2018
Dukc
Jun 12, 2018
Dukc
June 12, 2018
I have just managed to include a bit D code in a C# project compiled to Javascript. I am already looking at extending LDC runtime to open more possibilites, but something seems fishy.

All DRuntime code the compiler can invoke directly is in object.d, is that right?

When I try to copy a slice to another -no changing sizes, so can be done without GC- it compiles just fine using:

ldc2 -O1 -c dModule.d --output-bc -m32 -d-version="Emscripten_Backend"

...and when I proceed to compile the bytecode to Javascript:

emcc -O1 dModule.bc -g2 -s EXPORT_ALL=1 -s ASSERTIONS=1 -o dist/dModule.js

...it still works, but with a few warnings:

warning: Linking two modules of different target triples: C:\Users\Yleinen\.emscripten_cache\asmjs\dlmalloc_debug.bc' is 'asmjs-unknown-emscripten' whereas 'dModule.bc' is 'i686-pc-windows-msvc'

warning: Linking two modules of different data layouts: 'C:\Users\Yleinen\.emscripten_cache\asmjs\libc.bc' is 'e-p:32:32-i64:64-v128:32:128-n32-S128' whereas 'dModule.bc' is 'e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32'

warning: Linking two modules of different target triples: C:\Users\Yleinen\.emscripten_cache\asmjs\libc.bc' is 'asmjs-unknown-emscripten' whereas 'dModule.bc' is 'i686-pc-windows-msvc'

warning: incorrect target triple 'i686-pc-windows-msvc' (did you use emcc/em++ on all source files and not clang directly?)
warning: unresolved symbol: _d_array_slice_copy
warning: unresolved symbol: _d_arraybounds

The _d_array_slice_copy is now implemented in JavaScript by making it throw an exception about missing function. I would be happy to fix that function to exist, but there's something strange: object.d does not contain array_slice_copy, not even inside a version statement or static if. Where is it supposed to be found at, then?
June 12, 2018
On Tuesday, 12 June 2018 at 17:37:30 UTC, Dukc wrote:
> All DRuntime code the compiler can invoke directly is in object.d, is that right?

No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory.
June 12, 2018
On Tuesday, 12 June 2018 at 17:41:46 UTC, Adam D. Ruppe wrote:
> No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory.

That explains it. Well, back to exploring. Thank you.
June 12, 2018
On Tuesday, 12 June 2018 at 17:41:46 UTC, Adam D. Ruppe wrote:
> No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory.

And, just in case somebody at a later date has the same question, I found the function: It's in ldc.arrayinit.