[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-04-23 Thread bernhard via Phabricator via cfe-commits
bernhard added a comment.

Are there plans to offer a way to disable this behavior (or have it optional in 
the first place)?
We'd like to run some custom processing between wasm-ld and wasm-opt which 
can't happen after the latter due to some of its one-way destructive 
optimizations (i.e. memory-packing or simplify-globals passes).
The only way now is to tell our users to place wasm-opt somewhere where clang 
can't find it. Or instead of using one clang super-command to manually call 
-cc1 and wasm-ld separately which is disappointing.

Also, is it even common to place wasm-opt next to the clang executable? Who is 
this for? Is this documented?
I only stumbled into this by pure luck and was very confused for a while until 
I ran with -v.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70500/new/

https://reviews.llvm.org/D70500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-04-23 Thread bernhard via Phabricator via cfe-commits
bernhard added a comment.

> It's for users who want smaller wasm binaries. It's not currently documented, 
> though yes, it would be nice to document it.

But how would a user even end up with wasm-opt in the same directory of clang 
binaries?

> Clang and wasm-ld are free to do anything wasm-opt does. Could you describe 
> what you want to do in more detail? It may be possible to find alternative 
> approaches, or to design a feature for it with a clear and documentable scope.

I'm generating additional data segments which while doing so increases the 
initial memory pages count and shifts any globals that point to __heap_base and 
global[0] (stack ptr init).

Due to memory-packing the end of data becomes ambiguous (-export=__data_end 
would mitigate that but it's nice to be compatible with any un-opt'ed wasm 
file), and due to simplify-globals with remove-unused-module-elements the 
global[0] can get copied/moved directly into the code section.
I am aware that this treads very much in undocumented assumptions, it is still 
experimental but it works. This hidden execution of wasm-opt is mostly making 
documentation on my end a bit harder.

If wasm-ld were to do these passes on its own I think there would at least be 
options passable with -Xlinker to make it not do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70500/new/

https://reviews.llvm.org/D70500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-04-23 Thread bernhard via Phabricator via cfe-commits
bernhard added a comment.

> Would it work to increase the memory size, and then put your data in the new 
> space this creates at the end of memory?



> `__data_end` and `__heap_base` aren't things you can move around once the 
> linker has defined them. Their values can be baked in elsewhere in the wasm 
> module, so it's not safe in general to insert new memory in between them and 
> shift things around.

My plan was to embed arbitrary sized files directly into the data memory after 
the wasm file was created. But I think you're right, it ends up only working 
with simple wasm programs, more complex code crashes somewhere during 
`__wasm_call_ctors` with the approach I took.

I guess custom sections would be the official route but I was hoping to avoid 
having to pass the entire data through JavaScript before it reaches WASM land.

Also I'm very sorry to have hijacked this patch discussion with something very 
different. If you have some more hints for me how I could accomplish this I'd 
very gladly hear them, but if this is the wrong place we should probably leave 
it at that. Thank you for your time!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70500/new/

https://reviews.llvm.org/D70500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2020-05-02 Thread bernhard via Phabricator via cfe-commits
bernhard added a comment.

I had an application crash with optimizations enabled, so I wanted to keep the 
debug info but the automatic wasm-opt kept removing it and I lost another 30 
minutes to this, so I'm back :-)

Can we get clang not to automatically call wasm-opt if it is called without 
`-Xlinker -strip-all`, or when called with `-g` ?
Or at the very least, could it forward the `-g` along the `-O*` to wasm-opt?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70500/new/

https://reviews.llvm.org/D70500



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits