wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Fail to link after remove `dlmalloc.o` from `libc.a`

Open hangedfish opened this issue 2 years ago • 2 comments

about doc/pthread_library.md

dlmalloc.c define some alias functions and posix_memalign. Fail to link after remove dlmalloc.o from libc.a.

[build] wasm-ld: error: /opt/wasi-sdk-14.0/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc++abi.a(stdlib_new_delete.cpp.o): undefined symbol: posix_memalign
[build] wasm-ld: error: /opt/wasi-sdk-14.0/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(atexit.o): undefined symbol: __libc_calloc
[build] wasm-ld: error: /opt/wasi-sdk-14.0/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(freelocale.o): undefined symbol: __libc_free
[build] wasm-ld: error: /opt/wasi-sdk-14.0/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(locale_map.o): undefined symbol: __libc_malloc
[build] wasm-ld: error: /opt/wasi-sdk-14.0/bin/../share/wasi-sysroot/lib/wasm32-wasi/libc.a(locale_map.o): undefined symbol: __libc_malloc

hangedfish avatar May 04 '22 14:05 hangedfish

Hi, have you added the -Wl,--allow-undefined,--no-check-features option to wasi-sdk?

wenyongh avatar May 05 '22 08:05 wenyongh

Hi, have you added the -Wl,--allow-undefined,--no-check-features option to wasi-sdk?

I manage import symbols with linker options -Wl,--allow-undefined-file=import_symbols.txt, unexpected undefined symbols are not acceptable. posix_memalign had been register in lib_pthread_wrapper.c.

I fixed it by register other wrapper functions in libc_builtin_wrapper.c.

just like

static uint32
__libc_calloc_wrapper(Wasm_exec_env_t exec_env, uint32 nmemb, uint32 size)
{
    return calloc_wrapper(exec_env, nmemb, size);
}

hangedfish avatar May 05 '22 09:05 hangedfish