-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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: test.o: relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol version_getter; recompile with -fPIC #42738
Comments
Mild ping, if that’s ok? It would at least be good to at least know if this should work, or if it is unsupported. |
Just checked with latest revision 375226, and the problem still exists. |
The problem seems to be with clang, not lld: If I build with latest clang, but then try to link with wasm-ld from 358327 (the version that used to work), I still get that error. If I build witht the old clang, I can link with the new wasm-ld, it works. |
Reading a bit through the git log, maybe https://reviews.llvm.org/D61539 by Sam Clegg might be related, or any of these; git lg fc59a03..HEAD -G R_WASM_MEMORY_ADDR_LEB
|
Still present in 65f61c0 |
I did a git bisect (yay for moder tools), and found the commit that broke this for me:
|
Ha, I guess I can just use --target=wasm32-unknown-emscripten-wasm instead of --target=wasm32-unknown-unknown-wasm and things works. Not sure what the implications of this are, but it seems to unblock me for now. |
Hmm, this worked for a while (llvm10, using Unfortunately, I am a bit out of my depth here. |
Hmm, maybe it stopped working when using |
Is there any update? I'm suffering a similar issue. |
@llvm/issue-subscribers-lld-wasm |
Simplified example:
The problem only occurs when compiling with
As the warnings say the PIC ABI is somewhat experimental and that only place it is know to actually work and get tested is within emscripten. |
I think this can be closed as expected behaviour, but can you first confirm that using the emscripten triple with ToT works for you? |
@sbc100 I tested your emscripten triplet example, then It compiled successfully. |
Extended Description
This used to work at revision 358327, but seems to have stopped working with the 9 release. Consider the file (test.c:
int get_version() { return 0; }
int (*version_getter)() = &get_version;
attribute ((visibility("default"))) int version() { return (*version_getter)(); }
Compiling this with
clang-9 --compile -fpic -fvisibility=hidden --target=wasm32-unknown-unknown-wasm -fno-builtin -ffreestanding test.c -o test.o
wasm-ld -o test.wasm --import-memory --shared --no-entry --gc-sections --export=__wasm_call_ctors test.o
yields
wasm-ld: error: test.o: relocation R_WASM_MEMORY_ADDR_LEB cannot be used against symbol version_getter; recompile with -fPIC
But note that I am compiling it with -fPIC (and it used to work).
The text was updated successfully, but these errors were encountered: