Skip to content

Linux: Missing SONAME in "libwasmtime.so" hinders usage in CMake #2996

Closed
@MartinKolbAtWork

Description

@MartinKolbAtWork

The shared library libwasmtime.so does not have an SONAME specified. This can be checked using this command:
objdump -p libwasmtime.so | grep SONAME

When libwasmtime.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 (note: the CMake ticket refers to wasmer, but wasmtime has exactly the same issue, due to the Rust heritage):
https://gitlab.kitware.com/cmake/cmake/-/issues/22307#note_971562
The .so file should have a SONAME. If it doesn't, that's a bug in the package

I know that 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,libwasmtime.so");
}

I tried putting these lines into crates/wasi-common/build.rs, and then libwasmtime.so was built correctly, including a SONAME entry.

Could you please fix this issue?

Thanks
Martin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions