Description
Hi
I'm working on an STM32-based platform that runs a WebAssembly (WASM) application performing compute-intensive tasks involving double-precision and floating-point operations. Due to limited RAM and FLASH space, I aim to execute the WASM module directly from FLASH using Execute In Place (XIP).
Note:
I suspect that the --xip flag leads to "nan" and "integer overflows" when double values are very big or small. The same wasm module compiled without --xip in principle runs smoothly. Makes sense?
Toolchain
- Compiler: Clang (compiling C source files to WASM)
- AOT Compiler:
wamrc
(WebAssembly Micro Runtime Ahead-of-Time compiler)
Objective
Enable XIP to reduce memory footprint while maintaining full support for floating-point and double-precision computations.
Initial Approach
I compiled the WASM module using the following command:
./wamrc --xip --size-level=3 \
--target=thumbv8m.base \
--cpu=cortex-m33 \
--target-abi=eabi \
-o myfile_v8m.aot ./myfile.wasm
This enabled XIP as expected. However, at runtime, some double values were replaced by NaN, leading to incorrect calculations and integer overflows.
Following what is decribed in "https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/xip.md" I changed the compilation script to:
./wamrc --xip --size-level=3 \
--target=thumbv8m.base \
--cpu=cortex-m33 \
--target-abi=eabi \
--enable-builtin-intrinsics=fp.common \
-o myfile_v8m.aot ./myfile.wasm
With this configuration, the WASM module fails to load and outputs the following error:
AOT module load failed: cannot apply relocation to text section for aot file generated with "--enable-indirect-mode" flag
Am I missing something?