LDC wasm target: suppressing needless exports?

H. S. Teoh hsteoh at qfbox.info
Sat Feb 3 00:39:24 UTC 2024


On Thu, Feb 01, 2024 at 07:19:55PM +0000, ryuukk_ via Digitalmars-d wrote:
> oops, it is: ``--fvisibility=hidden``

On Thu, Feb 01, 2024 at 07:21:31PM +0000, ryuukk_ via Digitalmars-d wrote:
> Also this to optimize/trim your wasm files:
> 
> ``wasm-opt -Oz -o bin/game.wasm``
[...]

Cool, thanks!  That got rid of a lot of symbol bloat.

Now I've started putting together a minimal druntime so that I don't
have to compile with -betterC anymore.  Discovered that a good amount of
bloat comes from RTTI in the way of the TypeInfo_Xxx classes, which I
currently don't need.  Luckily, compiling with --fno-rtti allowed me to
eliminate TypeInfo from my minimal druntime (currently I have them
versioned out under version(RTTI), disabled by default) and keep the
bloat to a minimum.

Next step is to implement a dumb bump-the-pointer allocator so that
things like array concatenation would Just Work(tm). Well, provided you
don't do it inside a loop. I'm not planning to write a GC for wasm just
yet.

(Due to the possibility of passing references across the JS/wasm
boundary, and the fact that wasm code can't examine JS references or
even its own runtime stack, it may not actually be possible to implement
a sound GC at all. But now that V8 officially supports WasmGC, it's just
a matter of time before LLVM picks it up, then maybe I won't ever have
to implement a GC. :-P  It's kinda silly anyway since the wasm/JS host
already has a running GC; we just need a way of leveraging it from
inside the wasm sandbox. No sense bloating the wasm executable with a
full GC implementation when the host already has one!)

Anyway, all of this is making little steps toward the point where I
could just take a random D program and compile it for wasm, and with my
wasm JS shim and minimal druntime it should Just Work(tm).


T

-- 
Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at it. -- Pete Bleackley


More information about the Digitalmars-d mailing list