-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
wasm-ld: error: /tmp/wasm-shared-issue-60c549.o: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol .L.str; recompile with -fPIC #42059
Comments
This is actually WAI, but we should try to find a better way to convey the real error here. The problem is that Only We are looking into couple of options for fix this:
(1) might be a problem since many build system pass fPIC even when building static binaries and we want to continue to support that. (2) involves some design work to decided exactly how much info to embed and where in the object format. Perhaps (1) with just a warning and not an error might be acceptable is a quick solution? |
Interesting. So if I want to try out the dynamic linking support without using Emscripten, should I currently just use the target "wasm32-unknown-emscripten" (even though it's not actually Emscripten)? Or use a patched llvm with a new target (requiring long build times)? Given the word "yet", is this expected to work at some point? For ordinary architectures, it makes sense that a bare-metal target won't ever support dynamic linking, but WASM is different since it always has some kind of host environment. If it's intended to be supported, what exactly is preventing this now? But anyway, yeah, adding a warning sounds sensible as an easy short-term solution. |
Currently the dynamic linking ABI is still a work in progress: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md Originally I landed fPIC support in LLVM for wasm targets I caused some confusion since fPIC object files were not compatible with static linking (at least not until this change lands: https://reviews.llvm.org/D65922 PIC codegen was (temporarily I hope) disabled for non-emscripten triples: https://reviews.llvm.org/D62542. If you want to experiment I would just pass the emscripten triple for now, but be aware that this still a work in progress. Please let me know how you get on. |
Makes sense. My test code (https://github.com/ids1024/wasm-dynamic-test) works using the emscripten triple; so I'll use that for now. |
I believe this was fixed in https://reviews.llvm.org/D153293 |
@llvm/issue-subscribers-lld-wasm |
Extended Description
The attached C code fails to build with "clang --target=wasm32-unknown-unknown -fPIC -nostdlib -Wl,--shared -Wl,--export-all wasm-shared-issue.c".
The text was updated successfully, but these errors were encountered: