Skip to content

Commit

Permalink
fix: Set the SONAME to libwasmer.so on Linux.
Browse files Browse the repository at this point in the history
See wasmerio#2429 for more
context. I'm copy-pasting the original comment from @MartinKolbAtWork
here:

> 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**:
> rust-lang/cargo#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.
  • Loading branch information
Hywan committed Jun 18, 2021
1 parent 9e699ab commit 857d4da
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
rustflags = [
# Put the VM functions in the dynamic symbol table.
"-C", "link-arg=-Wl,-E",
# Fix the SONAME, required by CMake, see https://github.com/wasmerio/wasmer/issues/2429.
"-C", "link-arg=-Wl,-soname,libwasmer.so",
]

0 comments on commit 857d4da

Please sign in to comment.