Skip to content
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

engine-dylib with singlepass compiler fails on Mac with ld: illegal text-relocation #2736

Closed
tzemanovic opened this issue Dec 28, 2021 · 1 comment
Assignees
Labels
bug Something isn't working priority-medium Medium priority issue project-anoma
Milestone

Comments

@tzemanovic
Copy link

Hello, I'm trying to use engine-dylib together with the singlepass compiler.

Describe the bug

The simple wasm code in https://github.com/wasmerio/wasmer/blob/master/examples/engine_dylib.rs#L27 works fine, but when I tried to use some WASM code compiled from Rust instead, I noticed that this can in some cases fail in the linker with "ld: illegal text-relocation":

Shared object file generator failed with:
stderr:Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 \"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld\" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -arch x86_64 -platform_version macos 10.15.0 10.15.6 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -o /var/folders/8n/xzxk5c154qzg_chndqmzgfdr0000gp/T/wasmer_dylib_aOgbIS.dylib -L/usr/local/lib /var/folders/8n/xzxk5c154qzg_chndqmzgfdr0000gp/T/wasmer_dylib_07B9ou.o -undefined dynamic_lookup -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
ld: illegal text-relocation to '_wasmer_function__61' in /var/folders/8n/xzxk5c154qzg_chndqmzgfdr0000gp/T/wasmer_dylib_07B9ou.o from '_wasmer_function__0' in /var/folders/8n/xzxk5c154qzg_chndqmzgfdr0000gp/T/wasmer_dylib_07B9ou.o for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Concretely, it seems that the text-relocation is applied on code that uses function pointers.

Steps to reproduce

I've updated the example to demonstrate the issue with WASM code compiled from Rust code that uses a function pointer: heliaxdev@cb1833f

Expected behavior

The example should successfully load, compile and run the exported function (works on linux - returns Results: [I32(23)]).

@tzemanovic tzemanovic added the bug Something isn't working label Dec 28, 2021
@syrusakbary syrusakbary added this to the v2.x milestone Jan 30, 2022
@wchaudry wchaudry added this to 🌱 In progress in Wasmer Runtime Issue Board Feb 9, 2022
@wchaudry wchaudry moved this from 🌱 In progress to 📬 Backlog in Wasmer Runtime Issue Board Feb 9, 2022
@Amanieu Amanieu added the priority-medium Medium priority issue label Feb 9, 2022
@wchaudry wchaudry moved this from 📬 Backlog to 🌱 In progress in Wasmer Runtime Issue Board Feb 22, 2022
bors bot added a commit that referenced this issue Mar 17, 2022
2802: Feat/singlepass dylib r=ptitSeb a=ptitSeb

# Description
Enable Dylib+singlepass on Linux and macOS. Works fine, but larger wasm file may still fail to link on macOS/Aarch64.
For #2736 

Co-authored-by: ptitSeb <sebastien.chev@gmail.com>
@ptitSeb ptitSeb moved this from 🌱 In progress to Ready to Merge in Wasmer Runtime Issue Board Mar 18, 2022
@ptitSeb ptitSeb moved this from Ready to Merge to 🎉 Done in Wasmer Runtime Issue Board Mar 18, 2022
@epilys
Copy link
Contributor

epilys commented Jun 21, 2022

engine-dylib was removed in #2925 for the 3.0 release.

@epilys epilys closed this as completed Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-medium Medium priority issue project-anoma
Projects
Development

No branches or pull requests

5 participants