-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Clang in order to allow using the -shared option #199
Comments
Upstream LLVM's wasm32-wasi target does not support -shared yet. Can you say more about your use case and what -shared is being used for? |
It doesn't? Weird. I was trying to learn how to use Wasmtime from
Python. I assumed that in order to load a WASM module and call its
exported functions, it had to be built with the -shared option since
it's not an executable.
…On 10/11/21, Dan Gohman ***@***.***> wrote:
Upstream LLVM's wasm32-wasi target does not support -shared yet. Can you say
more about your use case and what -shared is being used for?
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#199 (comment)
|
There is a -shared option, but it was only implemented for Emscripten targets, and it doesn't work outside of Emscripten. The option in clang and wasi-sdk for building a wasm module without a main function is -mexec-model=reactor. |
Ok, how do I export symbols so that Wasmtime can find and call them? Simply compiling a .C file with some functions in it does not expose them. |
I believe you can either add |
@Keithcat1, you may be interested in #338? Let's close this issue since that PR is much newer and should resolve it. |
Hi,
I would like to build WASM modules that are loadable with the Wasmtime runtime, but this seems to require the -shared option and I ran into a couple errors while using that:
C:\py>
C:\py>C:\wasi-sdk\bin\clang -shared add.c
clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(__main_argc_argv.o): undefined symbol: main
clang: error: linker command failed with exit code 1 (use -v to see invocation)
C:\py>C:\wasi-sdk\bin\clang -Wl,--shared add.c
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(sbrk.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol errno; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol __heap_base; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol mparams; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol mparams; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol mparams; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol mparams; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol mparams; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol __heap_base; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol __heap_base; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol gm; recompile with -fPIC
wasm-ld: error: c:/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi\libc.a(dlmalloc.o): relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol __heap_base; recompile with -fPIC
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
C:\py>
clang version 11.0.0 (https://github.com/llvm/llvm-project 176249bd6732a8044d457092ed932768724a6f06)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: C:\wasi-sdk\bin
I wasn't able to use Emscripten because it seems to be generating WASM for the web but not for Wasmtime.
The text was updated successfully, but these errors were encountered: