In https://github.com/rust-lang/rust/issues/58343 I am describing some issue I am having with
-C rpath. The biggest problem is that it is always relative, meaning that if the binary is moved, the rpath breaks. This is a problem because even
cargo build will move the binary, meaning that rpath is basically useless when using cargo. (The absolute fallback path doesn't help at all, it points to a directory that does not even exist on my system.) Do you know why the rpath is relative?
I guess an alternative would be to tweak
cargo build and
cargo install such that they always create the binary in the target directory instead of moving it after it got built.
AIUI, rpath is intended to be relative to the binary so that you can ship around files like
mypackage/lib/myliband it will just find the right thing
cargo rustc -- -C link-args='-Wl,-rpath,$ORIGIN/../../../library/'
-C link-args sounds great
I can just add my absolute path there...