From 3f16b102d2a205b8de8a8eeefe70b54606dcb6a0 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 28 Jun 2022 20:56:24 +0900 Subject: [PATCH] doc/build_wasm_app.md: Mention a glitch with LLVM 13 and later (#1255) References: https://reviews.llvm.org/D81689#3611504 https://github.com/WebAssembly/WASI/issues/471 --- doc/build_wasm_app.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/build_wasm_app.md b/doc/build_wasm_app.md index 4034b1f5e..29cc91101 100644 --- a/doc/build_wasm_app.md +++ b/doc/build_wasm_app.md @@ -160,6 +160,11 @@ Firstly if libc-builtin (-nostdlib) mode meets the requirements, e.g. there are Most of the above methods are also available for libc-wasi mode, besides them, we can export malloc and free functions with `-Wl,--export=malloc -Wl,--export=free` option, so WAMR runtime will disable its app heap and call the malloc/free function exported to allocate/free the memory from/to the heap space managed by libc. +Note: wasm-ld from LLVM 13 and later automatically inserts dtor calls +for exported funtions. It breaks the malloc/free export mentioned above. +A workaround: Add `-Wl,--export=__wasm_call_ctors`, which happens to +prevent the automatic insertions for the current implementation. + ## 3. Build wasm app with pthread support Please ref to [pthread library](./pthread_library.md) for more details.