【发布时间】:2018-08-28 09:10:10
【问题描述】:
documentation 提供两个选项:让优化器去除不必要的代码,然后用您自己的替换 .js 胶水,或者使用 SIDE_MODULE 标志。
这两个选项都会导致 memory 导入(而不是导出),并且在 SIDE_MODULE 的情况下,还定义了大量额外的导入/导出。
将其与Webassembly Studio 提供的干净输出进行比较:
(module
(type $t0 (func))
(type $t1 (func (result i32)))
(func $__wasm_call_ctors (type $t0))
(func $main (export "main") (type $t1) (result i32)
i32.const 42)
(table $T0 1 1 anyfunc)
(memory $memory (export "memory") 2)
(global $g0 (mut i32) (i32.const 66560))
(global $__heap_base (export "__heap_base") i32 (i32.const 66560))
(global $__data_end (export "__data_end") i32 (i32.const 1024)))
这里导出了内存,并提供了__heap_base,方便我们自己编写分配器。 Emscripten 输出不会导出任何此类值,因此我们不知道从哪里开始分配内存。
是否可以使用emcc 获得类似的输出?
更新:似乎静态/堆栈大小由 emcc 内部确定,检索它们的唯一方法是解析生成的 .js 文件。侧模块是另一种野兽,如果我实际上不需要可重定位模块,我可能应该避免使用它们。
【问题讨论】:
标签: javascript emscripten webassembly