Browse Source

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.
pull/2923/head
Ayke van Laethem 2 years ago
committed by Ron Evans
parent
commit
b5c5d95b68
  1. 2
      .github/workflows/linux.yml
  2. 2
      Makefile
  3. 6
      targets/wasi.json
  4. 6
      targets/wasm.json

2
.github/workflows/linux.yml

@ -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

2
Makefile

@ -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
targets/wasi.json

@ -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
targets/wasm.json

@ -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",

Loading…
Cancel
Save