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.
Этот коммит содержится в:
родитель
633fe95187
коммит
b5c5d95b68
4 изменённых файлов: 14 добавлений и 2 удалений
2
.github/workflows/linux.yml
предоставленный
2
.github/workflows/linux.yml
предоставленный
|
@ -167,7 +167,7 @@ jobs:
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '12'
|
node-version: '14'
|
||||||
- name: Install wasmtime
|
- name: Install wasmtime
|
||||||
run: |
|
run: |
|
||||||
curl https://wasmtime.dev/install.sh -sSf | bash
|
curl https://wasmtime.dev/install.sh -sSf | bash
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -234,7 +234,7 @@ endif
|
||||||
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
|
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
|
||||||
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
|
@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.
|
# Build the Go compiler.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"llvm-target": "wasm32-unknown-wasi",
|
"llvm-target": "wasm32-unknown-wasi",
|
||||||
"cpu": "generic",
|
"cpu": "generic",
|
||||||
|
"features": "+bulk-memory,+nontrapping-fptoint,+sign-ext",
|
||||||
"build-tags": ["tinygo.wasm", "wasi"],
|
"build-tags": ["tinygo.wasm", "wasi"],
|
||||||
"goos": "linux",
|
"goos": "linux",
|
||||||
"goarch": "arm",
|
"goarch": "arm",
|
||||||
|
@ -8,6 +9,11 @@
|
||||||
"libc": "wasi-libc",
|
"libc": "wasi-libc",
|
||||||
"scheduler": "asyncify",
|
"scheduler": "asyncify",
|
||||||
"default-stack-size": 16384,
|
"default-stack-size": 16384,
|
||||||
|
"cflags": [
|
||||||
|
"-mbulk-memory",
|
||||||
|
"-mnontrapping-fptoint",
|
||||||
|
"-msign-ext"
|
||||||
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"--allow-undefined",
|
"--allow-undefined",
|
||||||
"--stack-first",
|
"--stack-first",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"llvm-target": "wasm32-unknown-wasi",
|
"llvm-target": "wasm32-unknown-wasi",
|
||||||
"cpu": "generic",
|
"cpu": "generic",
|
||||||
|
"features": "+bulk-memory,+nontrapping-fptoint,+sign-ext",
|
||||||
"build-tags": ["tinygo.wasm"],
|
"build-tags": ["tinygo.wasm"],
|
||||||
"goos": "js",
|
"goos": "js",
|
||||||
"goarch": "wasm",
|
"goarch": "wasm",
|
||||||
|
@ -8,6 +9,11 @@
|
||||||
"libc": "wasi-libc",
|
"libc": "wasi-libc",
|
||||||
"scheduler": "asyncify",
|
"scheduler": "asyncify",
|
||||||
"default-stack-size": 16384,
|
"default-stack-size": 16384,
|
||||||
|
"cflags": [
|
||||||
|
"-mbulk-memory",
|
||||||
|
"-mnontrapping-fptoint",
|
||||||
|
"-msign-ext"
|
||||||
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"--allow-undefined",
|
"--allow-undefined",
|
||||||
"--stack-first",
|
"--stack-first",
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче