From 0bd26e3b16207f8104ab2e901eb67aae2db1c193 Mon Sep 17 00:00:00 2001 From: Jack Lavigne Date: Thu, 14 Nov 2024 16:11:13 +0100 Subject: [PATCH] chore: bump build image and rust version, include memory features (#4) * chore: bump build image and rust version * chore: bump versions again * fix: use proper rustflags to include memory allocation info * chore: bump versions, update config.toml * fix: expose `commit_pages` to test * fix: `commit_pages` in the `wasm_snapshot_preview1` namespace --- .cargo/config.toml | 19 ++++++++++++++++--- rust-toolchain.toml | 2 +- scripts/run_docker_cmd.bat | 2 +- scripts/run_docker_cmd.sh | 2 +- src/test/setup.ts | 6 ++++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 3e65bf5c..d3787f7a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,11 +1,24 @@ [target.wasm32-wasi] rustflags = [ + "-Ctarget-feature=-crt-static,+bulk-memory", + "-Clink-self-contained=no", + "-Clink-arg=-l", + "-Clink-arg=c", + "-Clink-arg=/workdir/MSFS_SDK/WASM/wasi-sysroot/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a", + "-Clink-arg=-L", + "-Clink-arg=/workdir/MSFS_SDK/WASM/wasi-sysroot/lib/wasm32-wasi", "-Clink-arg=--export-table", + "-Clink-arg=--allow-undefined", + "-Clink-arg=--export-dynamic", + "-Clink-arg=--export=__wasm_call_ctors", "-Clink-arg=--export=malloc", "-Clink-arg=--export=free", - "-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi", - "-Clink-arg=-lclang_rt.builtins-wasm32" + "-Clink-arg=--export=mark_decommit_pages", + "-Clink-arg=--export=mallinfo", + "-Clink-arg=--export=mchunkit_begin", + "-Clink-arg=--export=mchunkit_next", + "-Clink-arg=--export=get_pages_state", ] [build] -target = "wasm32-wasi" \ No newline at end of file +target = "wasm32-wasi" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index df9cee29..d5ce77ec 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.72.1" +channel = "1.79.0" diff --git a/scripts/run_docker_cmd.bat b/scripts/run_docker_cmd.bat index 08f20966..3b830f12 100644 --- a/scripts/run_docker_cmd.bat +++ b/scripts/run_docker_cmd.bat @@ -1,6 +1,6 @@ @echo off -set image="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4" +set image="ghcr.io/flybywiresim/dev-env@sha256:aa36c0e4b8c66c2ec0195a104f8ae04a8ffbf45e8ddb6a8aca4f7237436bd876" cd %~dp0 diff --git a/scripts/run_docker_cmd.sh b/scripts/run_docker_cmd.sh index 2f678f26..74b1f34d 100755 --- a/scripts/run_docker_cmd.sh +++ b/scripts/run_docker_cmd.sh @@ -1,6 +1,6 @@ #!/bin/bash -IMAGE="ghcr.io/flybywiresim/dev-env@sha256:528f8e1ca9063b9346c7d4f684d7aadbcb58ca1fba2b1a3c2cdd9c820c4236f4" +IMAGE="ghcr.io/flybywiresim/dev-env@sha256:aa36c0e4b8c66c2ec0195a104f8ae04a8ffbf45e8ddb6a8aca4f7237436bd876" cd "$(dirname "$0")" diff --git a/src/test/setup.ts b/src/test/setup.ts index 5e71977d..09588259 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -160,7 +160,9 @@ const promiseResults = new Map() const failedRequests: bigint[] = [] wasmInstance = new WebAssembly.Instance(wasmModule, { - wasi_snapshot_preview1: wasiSystem.wasiImport, + wasi_snapshot_preview1: Object.assign(wasiSystem.wasiImport, { + commit_pages: () => { }, // Empty implementation of this function as it is needed for the WASM module to properly load + }), env: { fsCommBusCall: (eventNamePointer: number, args: number) => { const eventName = readString(eventNamePointer) @@ -236,7 +238,7 @@ wasmInstance = new WebAssembly.Instance(wasmModule, { return 3 // FS_NETWORK_HTTP_REQUEST_STATE_DATA_READY } return 2 // FS_NETWORK_HTTP_REQUEST_STATE_WAITING_FOR_DATA - }, + } }, }) as WasmInstance