[llvm-dev] Wasm, start function, and default globals
Bill Ticehurst via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 15 16:50:24 PDT 2019
Apologies if there is a better forum for these questions. Please redirect me if so.
I’ve been using the clang/wasm-ld tools to experiment with some basic examples, and there’s a couple things I’m wrestling with.
1) How to denote a function as the “start” function (https://webassembly.github.io/spec/core/binary/modules.html#start-section)
2) How to avoid the defaulted __heap_base global.
I’ve dug around on the samples, mailing lists, and in the wasm-ld code for an attribute or flag to specify the start function, but don’t see anything. Is this just not implemented (or tracked) yet?
For 2), I always see the below global in the compiled output even with the most trivial code that makes no reference to it (e.g. compiling just a simple function that only references values on the implicit operand stack).
(global (;0;) (mut i32) (i32.const 66560))
Per https://dassur.ma/things/c-to-webassembly/, looks like this is the __heap_base value implicitly provided for modeling the stack/heap as are usually present in most C/C++ environments, even though unused in my compiled output. Is this something that could/should be optimized away, but again just isn’t implemented yet? Any way to suppress this building with the current clang/wasm-ld toolchain?
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev