wasm: is target_features+mutable-globals+sign-ext required?
python script here to test wasm output sizes of C3 vs Zig. https://github.com/brentharts/c3_vs_zig
I noticed in the simple hello world test the C3 wasm has at the end: \x00,\x0ftarget_features\x02+\x0fmutable-globals+\x08sign-ext
I'm using this python function to strip this away before calling wasm-opt -Oz ...
My other tests are still working, so it appears that removing target_features+mutable-globals+sign-ext is safe (tested only in FireFox), when will it break? The Zig wasm does not have this.
When stripped and after wasm-opt, C3 wasm is a few bytes smaller than Zig.
I don't pass those arguments to LLVM, so it's likely that they form some kind of default? What does Clang output?
With emcc -Oz the output wasm does not have: target_features+mutable-globals+sign-ext
And Zig did not have these either? I see that Zig explicitly adds those to the functions. Can you perhaps run emcc and output some LLVM for the same example and I could look at that one to determine the optimal output. 🙏
confirmed that zig 0.13 and 0.13 and emcc 3.1.6 do not add target_features+mutable-globals+sign-ext
looking online i found: https://reviews.llvm.org/D88506 """ wasm-ld --features=mutable-globals --export-all
Note that this will not export linker-generated mutable globals unless the resulting binaryen already includes the 'mutable-globals' features since that would otherwise create and invalid binaryen. """
https://clang.llvm.org/doxygen/Basic_2Targets_2WebAssembly_8cpp_source.html
'''c++
bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
return llvm::StringSwitch
https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190408/643578.html
It looks like if mutable-globals and sign-ext isn't added to all functions it's added during linking then?