diff options
| author | bors <bors@rust-lang.org> | 2024-07-03 14:15:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-03 14:15:31 +0000 |
| commit | 1086affd98ad746e1bb02e187562b9a037e854e3 (patch) | |
| tree | cd568ed186a6ba2a57459b82f2182895746a2a08 /tests | |
| parent | c872a1418a4be3ea84a8d5232238b60d35339ba9 (diff) | |
| parent | 565ddfb48ca2a3b24236c2b393ec14eb86d64a7a (diff) | |
| download | rust-1086affd98ad746e1bb02e187562b9a037e854e3.tar.gz rust-1086affd98ad746e1bb02e187562b9a037e854e3.zip | |
Auto merge of #126094 - petrochenkov:libsearch, r=michaelwoerister
linker: Link dylib crates by path Linkers seem to support linking dynamic libraries by path. Not sure why the previous scheme with splitting the path into a directory (passed with `-L`) and a name (passed with `-l`) was used (upd: likely due to https://github.com/rust-lang/rust/pull/126094#issuecomment-2155063414). When we split a library path `some/dir/libfoo.so` into `-L some/dir` and `-l foo` we add `some/dir` to search directories for *all* libraries looked up by the linker, not just `foo`, and `foo` is also looked up in *all* search directories not just `some/dir`. Technically we may find some unintended libraries this way. Therefore linking dylibs via a full path is both simpler and more reliable. It also makes the set of search directories more easily reproducible when we need to lookup some native library manually (like in https://github.com/rust-lang/rust/pull/123436).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/dylib-soname/foo.rs | 1 | ||||
| -rw-r--r-- | tests/run-make/dylib-soname/rmake.rs | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/run-make/dylib-soname/foo.rs b/tests/run-make/dylib-soname/foo.rs new file mode 100644 index 00000000000..6833f391999 --- /dev/null +++ b/tests/run-make/dylib-soname/foo.rs @@ -0,0 +1 @@ +pub fn something() {} diff --git a/tests/run-make/dylib-soname/rmake.rs b/tests/run-make/dylib-soname/rmake.rs new file mode 100644 index 00000000000..a0215a6906e --- /dev/null +++ b/tests/run-make/dylib-soname/rmake.rs @@ -0,0 +1,19 @@ +// Checks that produced dylibs have a relative SONAME set, so they don't put "unmovable" full paths +// into DT_NEEDED when used by a full path. + +//@ only-linux +//@ ignore-cross-compile + +use run_make_support::regex::Regex; +use run_make_support::{cmd, run_in_tmpdir, rustc}; + +fn main() { + run_in_tmpdir(|| { + rustc().crate_name("foo").crate_type("dylib").input("foo.rs").run(); + cmd("readelf") + .arg("-d") + .arg("libfoo.so") + .run() + .assert_stdout_contains("Library soname: [libfoo.so]"); + }); +} |
