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_971562The 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

Most upvoted comments

In #2449, I’m using the cdylib-link-lines crate 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.so via Makefile, like so:

make --directory=<repo-dir> build-capi 
make --directory=<repo-dir> package-capi 

After the two build steps, you can check with objdump that SONAME is not present: objdump -p <repo-dir>/package/lib/libwasmer.so | grep SONAME

Could 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