emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.74k stars 3.3k forks source link

[wasm-split] Inbuilt instrumentation support with threads enabled #22420

Open ravisumit33 opened 1 month ago

ravisumit33 commented 1 month ago

Currently, emscripten instruments wasm binaries without using --in-memory or --in-secondary-memory wasm-split options when threads are enabled here. Even docs mention using --in-memory for multithreaded programs. I have few questions regarding this:

  1. Do we need to re-instrument the wasm binary ourselves for multithreaded programs? Or has emscripten planned to provide support for this?
  2. Docs also suggest to use -sGLOBAL_BASE flag with --in-memory wasm-split option. What about --in-secondary-memory option? Do we still need to use that flag if we use the later option?
ravisumit33 commented 1 month ago

@tlively @sbc100 Thoughts?

tlively commented 1 month ago

Yes, right now you would have to re-instrument the binary yourself to use one of those options. Ideally we would support --in-secondary-memory to avoid having to mess with -sGLOBAL_BASE, but Emscripten does not currently know how to provide the second memory when instantiating the module, so your best bet is to use --in-memory and set an appropriate -sGLOBAL_BASE.