www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - LDC to WASM failed?

reply KnightMare <black80 bk.ru> writes:
I tried to compile the program as written in the article
https://wiki.dlang.org/Generating_WebAssembly_with_LDC
first sample add (not callback).

compilation is ok, I've got wasm.wasm that looks in binary like 
this
https://pastebin.com/JBr7V6if

but browser console says:
request sent wasm.html:20:7
response received wasm.html:8:9
instantiated wasm.html:12:11
TypeError: exports.add is not a function[Learn More] 
wasm.html:15:21

well, in binary representation wasm.wasm I dont see any text 
"add" (IMO method name should exists in any case when JS wants 
call it)

my current LDC version is 1.16.0.beta1

2nd question:
I understand that I cant import anything from Phobos yet, isnt it?
does LDC will give some wasm runtime in future?
May 11 2019
parent reply kinke <noone nowhere.com> writes:
On Saturday, 11 May 2019 at 16:44:20 UTC, KnightMare wrote:
 well, in binary representation wasm.wasm I dont see any text 
 "add"
There was a breaking change with LLD 8, requiring to use `-L--export-dynamic` in the LDC command-line. Is/will be fixed: https://github.com/ldc-developers/ldc/pull/3072
 2nd question:
 I understand that I cant import anything from Phobos yet, isnt 
 it?
You can, if it's templates only without any dependency on C runtime and non-templated druntime+Phobos. See the touched test in the PR above for an example.
 does LDC will give some wasm runtime in future?
The compiler won't, but the community might; you're not the only one interested in some form of baremetal libraries, e.g., see https://forum.dlang.org/thread/szfzoaoizbgjzfpckmze forum.dlang.org.
May 11 2019
parent KnightMare <black80 bk.ru> writes:
 There was a breaking change with LLD 8, requiring to use 
 `-L--export-dynamic` in the LDC command-line. Is/will be fixed: 
 https://github.com/ldc-developers/ldc/pull/3072
thank. it worked. I will see what's next
May 11 2019