I'm working on a C++/Wasm-Module and have a hard time with clang and wasm-ld .
the toolchain lets me use builtin functions like
just fine. The following functions are accepted by clang, but cannot be resolved by wasm-ld.
wasm-ld: error: lto.tmp: undefined symbol: memcpy
below are the flags i pass to clang and wasm-ld in my makefile: weird is, that even though i explicitly call the builtin function, clang emits the clib name.
// clang.exe
CLANGFLAGS = \
-c \
--target=wasm32 \
-Os \
-flto \
--include-directory=.
//wasm-ld.exe
LDFLAGS = \
-O3 \
--no-entry \
--strip-all \
--export-dynamic \
--lto-O3 \
--gc-sections
--std=c++20
what i have tried:
extern "C" void* memset(void* pMemory, i32 value, size_t length) noexcept {
return __builtin_memset(pMemory, value, length);
}
Google didn't have a good advice 'til now. But maybe you guys do.
I Confirm the suggestion by Hasturkun :
The memory builtins get enabled by -mbulk-memory. See stackoverflow.com/a/67084011 for a more details.
clang -c --target=wasm32 -mbulk-memory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.