www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - All symbols exported on wasm target

reply Sebastiaan Koppe <mail skoppe.eu> writes:
I am doing a lot of wasm [1] compilation with ldc lately, and I 
have noticed that all symbols get exported regardless of what I 
try. E.g. strip-all wont strip any, etc.

When I strip things manually I can sometimes get something from 
90kb to 9kb, so it really is substantial.

According to [2], on clang you can workaround this, by adding 
__attribute__((visibility("default"))) to each function you want 
exported.

Any similar solution for ldc?

[1] https://github.com/skoppe/spasm
[2] https://aransentin.github.io/cwasm/
Nov 03 2018
parent reply Johan Engelen <j j.nl> writes:
On Saturday, 3 November 2018 at 11:12:42 UTC, Sebastiaan Koppe 
wrote:
 I am doing a lot of wasm [1] compilation with ldc lately, and I 
 have noticed that all symbols get exported regardless of what I 
 try. E.g. strip-all wont strip any, etc.
You could testdrive this PR: https://github.com/ldc-developers/ldc/pull/2894 -Johan
Nov 03 2018
next sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Saturday, 3 November 2018 at 12:45:25 UTC, Johan Engelen wrote:
 On Saturday, 3 November 2018 at 11:12:42 UTC, Sebastiaan Koppe 
 wrote:
 I am doing a lot of wasm [1] compilation with ldc lately, and 
 I have noticed that all symbols get exported regardless of 
 what I try. E.g. strip-all wont strip any, etc.
You could testdrive this PR: https://github.com/ldc-developers/ldc/pull/2894 -Johan
That is nice. Will try tonight.
Nov 03 2018
prev sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Saturday, 3 November 2018 at 12:45:25 UTC, Johan Engelen wrote:
 On Saturday, 3 November 2018 at 11:12:42 UTC, Sebastiaan Koppe 
 wrote:
 I am doing a lot of wasm [1] compilation with ldc lately, and 
 I have noticed that all symbols get exported regardless of 
 what I try. E.g. strip-all wont strip any, etc.
You could testdrive this PR: https://github.com/ldc-developers/ldc/pull/2894 -Johan
The pull request works wonders! I just add 'export' where I need it, and voila! I did notice some other garbage though... (compared to ldc1.12.0) It might be completely unrelated to the pull request, but I noticed extra *__initZ wasm globals being generated (at least 50 extra I never saw with 1.12), as well as _d_arraybounds, some toHash's and opEquals, and more static data in the data section (probably related to the __init's). Need to check without the pull request...
Nov 04 2018
parent reply kinke <noone nowhere.com> writes:
On Sunday, 4 November 2018 at 21:22:07 UTC, Sebastiaan Koppe 
wrote:
 It might be completely unrelated to the pull request, but I 
 noticed extra *__initZ wasm globals being generated (at least 
 50 extra I never saw with 1.12), as well as _d_arraybounds, 
 some toHash's and opEquals, and more static data in the data 
 section (probably related to the __init's).
Are you sure you didn't just forget -betterC?
Nov 04 2018
parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Sunday, 4 November 2018 at 21:40:13 UTC, kinke wrote:
 Are you sure you didn't just forget -betterC?
I didn't, but dub did. With dub 1.11.0, the betterC dflags I set in a dependency project got propagated to the root package. With dub 1.12.0, that is no longer the case, and I have to set the betterC flag on both projects. I went through the dub commits but couldn't find anything...
Nov 05 2018