Open phi-gamma opened 1 year ago
What would be your expectation ? Can you please share the example repository so I can have a look?
what happens if you do not use the build.rs at all?
What would be your expectation ?
libdependency.so
has an SONAME of libdependency.so.0
. (This is the case now.)libmain.so
has an SONAME of libmain.so.0
. (Is libdependency.so.0
now, which is wrong.)Can you please share the example repository so I can have a look?
Demo: https://gitlab.com/phgsng/buggy-soname
what happens if you do not use the build.rs at all?
The objects lack DT_SONAME
.
I doublechecked and a single rustc-cdylib-link-arg is produced per crate name, looks like it is cargo doing something strange itself, you can try by emitting manually rustc-cdylib-link-arg to confirm.
Yeah, I realized that as well. If you wish, you could perhaps contribute to the discussion on the Rust forums:
https://users.rust-lang.org/t/suppress-link-arg-in-dependency/89245
FWIW I’m investigating adding a patchelf
step to the
cargo handler in our build process to fix up broken
DT_SONAMES.
It is better to report the issue on the cargo tracker, I'm afraid I won't have enough time to look into it if not in the weekend.
Probably a good idea; I reported my case on the cargo issue.
You might have better luck with https://crates.io/crates/cargo-c. It is aware of workspaces and provides additional niceties.
2023-02-14 (Tuesday), @.*** (Luca Barbato):
You might have better luck with https://crates.io/crates/cargo-c. It is aware of workspaces and provides additional niceties.
Thanks, I’m aware of cargo-c
but haven’t found time to
evaluate it yet.
Wrong SONAME if dependending on another dylib crate
When building a shared library that itself depends on another
dylib
type library, both libraries’ SONAMEs are passed to the linker of the depending (main) library, causing the SONAME of the dependency (which comes last) to be embedded in the resulting object.In this example workspace:
both members are libraries with
crate_type = [ "lib", "cdylib" ]
and thisbuild.rs
:Building with cargo results in this rustc invocation for
libmain.so
:– that last line obviously being misplaced. (The line for
libdependency.so
is fine.) As a result: