-
Notifications
You must be signed in to change notification settings - Fork 26
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
Link to libatomic for 32-bit builds #53
Comments
Thanks for the details! ❤️ I'm not sure where to put that, but I guess it's in the .cargo file. I just don't know the syntax. Maybe it's in the "rustflags". I found this option described in the docs: https://doc.rust-lang.org/rustc/command-line-arguments.html#option-l-link-lib I can´t try it right now, but tomorrow I can test that. |
See philss/rustler_precompiled#53 for more details.
This is needed in order to make the precompiled NIF work on ARM 32 bits that is used in some Raspbery Pi machines (32 bits). See: philss/rustler_precompiled#53
I was able to add the Here is the output of the command
Here is the PR: elixir-explorer/explorer#544 I plan to release a new version with the fix. |
Nice! Looks like it worked! Thanks! |
This is needed in order to make the precompiled NIF work on ARM 32 bits that is used in some Raspbery Pi machines (32 bits). See: philss/rustler_precompiled#53
@fhunleth version Also, do you think that this problem affects all the NIFs using Rustler? Probably not, right? |
@philss I'm running I wish I knew an easy way to tell when libatomic is needed without running |
I'm closing this for now. But I think it would worth to add a troubleshooting guide to this types of errors. I just don't know how to point the user to the "missing link". Anyway, if appears again, we can try to add this guide. |
This is needed in order to make the precompiled NIF work on ARM 32 bits that is used in some Raspbery Pi machines (32 bits). See philss/rustler_precompiled#53
libatomic
functions are being put into executables for 32-bit platforms. 64-bit targets are unaffected (I checked aarch64 and riscv64). This seems to affect other projects like rust-openssl (see https://github.com/sfackler/rust-openssl/pull/1547/files). The fix hopefully is the same. Given my unfamiliarity with Rustler and RustlerPrecompiled, I'm not sure where the best place is to add thecargo:rustc-link-lib=dylib=atomic
option that therust-openssl
PR had.Specifically, this causes libraries using RustlerPrecompiled to fail to load. The error message for
libexplorer-v0.5.4-nif-2.16-arm-unknown-linux-gnueabihf.so
is that__atomic_store_8
can't be found.Running
readelf -d
onlibexplorer-v0.5.4-nif-2.16-arm-unknown-linux-gnueabihf.so
shows the following:You can see that
libatomic.so.1
isn't in the list of needed shared libraries. However, if you runreadelf -s
onlibexplorer-v0.5.4-nif-2.16-arm-unknown-linux-gnueabihf.so
and grep foratomic
, you'll see:So
libatomic
is being used. Addinglibatomic.so.1
to the needed shared libraries list fixes that. I manually added it withpatchelf
:$ patchelf --add-needed libatomic.so.1 ./_build/rpi3_dev/lib/explorer/priv/native/libexplorer-v0.5.4-nif-2.16-arm-unknown-linux-gnueabihf.so $ readelf -d ./_build/rpi3_dev/lib/explorer/priv/native/libexplorer-v0.5.4-nif-2.16-arm-unknown-linux-gnueabihf.so bumblebee* Dynamic section at offset 0x2247000 contains 34 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [libatomic.so.1] 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x00000001 (NEEDED) Shared library: [librt.so.1] 0x00000001 (NEEDED) Shared library: [libpthread.so.0] 0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libdl.so.2] 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x00000001 (NEEDED) Shared library: [ld-linux-armhf.so.3]
Once I did that,
explorer
loaded and worked fine on the Raspberry Pi 3 which was being run in 32-bit mode w/ Nerves.All that I believe that needs to be done is to add
cargo:rustc-link-lib=dylib=atomic
to the right place. Checking that it worked can be done withreadelf -d
, so there's no need to run on a Raspberry Pi 3 or anything. I don't know of a downside of unconditionally adding it for 32-bit Rust builds.I hope this makes sense and there's a good place to put it.
The text was updated successfully, but these errors were encountered: