wasmer: Linux: Missing SONAME in "libwasmer.so" hinders usage in CMake
The shared library libwasmer.so does not have an SONAME specified. This can be checked using this command:
objdump -p libwasmer.so | grep SONAME
When libwasmer.so is consumed in CMake, the linker produces a wrong output file due to the missing SONAME.
There is a workaround for this in CMake, but according to a reply from the CMake folks, the missing SONAME is a bug that must be fixed by the library provider:
https://gitlab.kitware.com/cmake/cmake/-/issues/22307#note_971562
“The libwasmer.so file should have a SONAME. If it doesn’t, that’s a bug in the wasmer package”
The problem is inherent for all Rust builds of cdylibs: https://github.com/rust-lang/cargo/issues/5045
The Rust community did not fix this since 2018 (see issue above), but fortunately it’s easy to fix for library creators. You just need to put the following code into the build.rs of the library:
if cfg!(target_os = "linux") {
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libwasmer.so");
}
I tried putting these lines into lib/c-api/build.rs, and then libwasmer.so was built correctly, including a SONAME entry.
Could you please fix this issue?
Thanks Martin
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (12 by maintainers)
Commits related to this issue
- fix: Set the SONAME to `libwasmer.so` on Linux. See https://github.com/wasmerio/wasmer/issues/2429 for more context. I'm copy-pasting the original comment from @MartinKolbAtWork here: > The shared l... — committed to Hywan/wasmer by Hywan 3 years ago
- fix: Set the SONAME to `libwasmer.so` on Linux. See https://github.com/wasmerio/wasmer/issues/2429 for more context. I'm copy-pasting the original comment from @MartinKolbAtWork here: > The shared l... — committed to Hywan/wasmer by Hywan 3 years ago
- fix: Set the SONAME to `libwasmer.so` on Linux. See https://github.com/wasmerio/wasmer/issues/2429 for more context. I'm copy-pasting the original comment from @MartinKolbAtWork here: > The shared l... — committed to Hywan/wasmer by Hywan 3 years ago
- fix: Set the SONAME to `libwasmer.so` on Linux. See https://github.com/wasmerio/wasmer/issues/2429 for more context. I'm copy-pasting the original comment from @MartinKolbAtWork here: > The shared l... — committed to Hywan/wasmer by Hywan 3 years ago
- Merge #2430 2430: fix: Set the SONAME to `libwasmer.so` on Linux r=syrusakbary a=Hywan # Description See https://github.com/wasmerio/wasmer/issues/2429 for more context. The idea is to use ou... — committed to wasmerio/wasmer by bors[bot] 3 years ago
- feat: Sync the code with `cargo-c`. As discussed in https://github.com/wasmerio/wasmer/issues/2429#issuecomment-864925634, it would be ideal if this crate could get synchronized with `cargo-c` which ... — committed to Hywan/cdylib-link-lines by Hywan 3 years ago
- feat: Sync the code with `cargo-c`. As discussed in https://github.com/wasmerio/wasmer/issues/2429#issuecomment-864925634, it would be ideal if this crate could get synchronized with `cargo-c` which ... — committed to lu-zero/cdylib-link-lines by Hywan 3 years ago
- Merge #2457 2457: fix(c-api) Rename lib's name to `wasmer` r=Hywan a=Hywan # Description This patch does several things. 1. For the crate `wasmer-c-api`, the library name is modified from ... — committed to wasmerio/wasmer by bors[bot] 3 years ago
In #2449, I’m using the
cdylib-link-linescrate to handle everything properly. I hope it will solve the problem for all platforms @MartinKolbAtWork 😃.Pull requests are always welcome 😃
You can fetch the pre-built cargo-c from the releases and it would have a negligible impact.
It would reduce the build time if you could move away some of the custom header logic, but that could be the discussion for another issue I guess 😃
Hi @Hywan and @syrusakbary,
thanks for the provided fix. However, as mentioned before, the fix does not work when building
libwasmer.sovia Makefile, like so:After the two build steps, you can check with objdump that SONAME is not present:
objdump -p <repo-dir>/package/lib/libwasmer.so | grep SONAMECould you please reopen the issue and consider the solution that I suggested (using build.rs) or any other solution that works via the Makefile build?
Thanks, Martin