wasm: use newer WebAssembly features

This commit will start to use a few more WebAssembly features, such as
bulk memory operations. This results in a significant code size saving.
How much it saves varies a lot but it's typically around 1300 bytes.

This change is possible by bumping our minimum Node.js version to 14.
The previous LTS version (12) has been marked end of life, so we can
start to depend on features in the current oldest LTS version, which is
version 14. Browsers have been supporting these features for a long time
now, it's just Node.js that prevented us doing this before.
This commit is contained in:
Ayke van Laethem
2022-06-16 03:41:27 +02:00
committed by Ron Evans
parent 633fe95187
commit b5c5d95b68
4 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'
- name: Install wasmtime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
+1 -1
View File
@@ -234,7 +234,7 @@ endif
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
cd lib/wasi-libc && make -j4 WASM_CFLAGS="-O2 -g -DNDEBUG" MALLOC_IMPL=none CC=$(CLANG) AR=$(LLVM_AR) NM=$(LLVM_NM)
cd lib/wasi-libc && make -j4 WASM_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC=$(CLANG) AR=$(LLVM_AR) NM=$(LLVM_NM)
# Build the Go compiler.
+6
View File
@@ -1,6 +1,7 @@
{
"llvm-target": "wasm32-unknown-wasi",
"cpu": "generic",
"features": "+bulk-memory,+nontrapping-fptoint,+sign-ext",
"build-tags": ["tinygo.wasm", "wasi"],
"goos": "linux",
"goarch": "arm",
@@ -8,6 +9,11 @@
"libc": "wasi-libc",
"scheduler": "asyncify",
"default-stack-size": 16384,
"cflags": [
"-mbulk-memory",
"-mnontrapping-fptoint",
"-msign-ext"
],
"ldflags": [
"--allow-undefined",
"--stack-first",
+6
View File
@@ -1,6 +1,7 @@
{
"llvm-target": "wasm32-unknown-wasi",
"cpu": "generic",
"features": "+bulk-memory,+nontrapping-fptoint,+sign-ext",
"build-tags": ["tinygo.wasm"],
"goos": "js",
"goarch": "wasm",
@@ -8,6 +9,11 @@
"libc": "wasi-libc",
"scheduler": "asyncify",
"default-stack-size": 16384,
"cflags": [
"-mbulk-memory",
"-mnontrapping-fptoint",
"-msign-ext"
],
"ldflags": [
"--allow-undefined",
"--stack-first",