LDC wasm target: suppressing needless exports?
ryuukk_
ryuukk.dev at gmail.com
Thu Feb 1 19:19:05 UTC 2024
On Thursday, 1 February 2024 at 18:41:10 UTC, H. S. Teoh wrote:
> Lately I've been playing around with targeting wasm using LDC's
> wasm target. (So far got enough of it working that I can write
> betterC-level D code and have it work in the browser --
> certainly a welcome change from having to deal with
> Javascript's oddities and limitations. Plans are on the way to
> getting a rudimentary minimal druntime running so that I can
> start writing "real" D. :-P)
>
> One thing I noticed, though, is that LDC seems to export all
> functions (including private ones!) to the generated .wasm
> file's export section. Meaning that they can be accessed from
> the JS side, etc.. Most of this is actually unnecessary,
> though, since I only have about 2-3 functions that actually
> need to be called from JS; everything else is internal D code.
> Is there a way to suppress this auto-exporting and only do it
> for a few select functions?
>
> It's mostly harmless, except that when I start using template
> functions the size of the symbols explode and needlessly bloats
> up my .wasm executable. Would be nice to trim off this fat.
>
>
> T
Try to compile with:
``--f-visibility=hidden``
More information about the Digitalmars-d
mailing list