Skip to content

Commit 94ab101

Browse files
jieyouxuOneirical
andcommitted
tests: migrate libs-through-symlink to rmake.rs
- Document test intent, backlink to #13890 and fix PR #13903. - Fix the test logic: the `Makefile` version seems to not actually be exercising the "library search traverses symlink" logic, because the actual symlinked-to-library is present under the directory tree when `bar.rs` is compiled, because the `$(RUSTC)` invocation has an implicit `-L $(TMPDIR)`. The symlink itself was actually broken, i.e. it should've been `ln -nsf $(TMPDIR)/outdir/$(NAME) $(TMPDIR)` but it used `ln -nsf outdir/$(NAME) $(TMPDIR)`. Co-authored-by: Oneirical <[email protected]>
1 parent 6d3db55 commit 94ab101

File tree

3 files changed

+42
-23
lines changed

3 files changed

+42
-23
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ run-make/branch-protection-check-IBT/Makefile
22
run-make/cat-and-grep-sanity-check/Makefile
33
run-make/extern-fn-reachable/Makefile
44
run-make/jobserver-error/Makefile
5-
run-make/libs-through-symlinks/Makefile
65
run-make/split-debuginfo/Makefile
76
run-make/symbol-mangling-hashed/Makefile
87
run-make/translation/Makefile

tests/run-make/libs-through-symlinks/Makefile

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//! Regression test for [rustc doesn't handle relative symlinks to libraries
2+
//! #13890](https://github.com/rust-lang/rust/issues/13890).
3+
//!
4+
//! `rustc` searches by default for libraries in its current directory, but used to have difficulty
5+
//! locating a library if it is provided behind a symlink, e.g.
6+
//!
7+
//! ```text
8+
//! actual_dir/
9+
//! libfoo.rlib
10+
//! symlink_dir/ # $CWD set; rustc -L . bar.rs that depends on foo
11+
//! libfoo.rlib --> ../actual_dir/libfoo.rlib
12+
//! ```
13+
//!
14+
//! Previously, if `rustc` was invoked with CWD set to `symlink_dir/`, it would fail to traverse the
15+
//! symlink to locate `actual_dir/libfoo.rlib`.
16+
17+
//@ ignore-cross-compile
18+
19+
use run_make_support::{bare_rustc, cwd, path, rfs, rust_lib_name};
20+
21+
fn main() {
22+
let actual_lib_dir = path("actual_lib_dir");
23+
let symlink_lib_dir = path("symlink_lib_dir");
24+
rfs::create_dir_all(&actual_lib_dir);
25+
rfs::create_dir_all(&symlink_lib_dir);
26+
27+
// NOTE: `bare_rustc` is used because it does not introduce an implicit `-L .` library search
28+
// flag.
29+
bare_rustc().input("foo.rs").output(actual_lib_dir.join(rust_lib_name("foo"))).run();
30+
31+
rfs::symlink_file(
32+
actual_lib_dir.join(rust_lib_name("foo")),
33+
symlink_lib_dir.join(rust_lib_name("foo")),
34+
);
35+
36+
// Make rustc's $CWD be in the directory containing the symlink-to-lib.
37+
bare_rustc()
38+
.current_dir(&symlink_lib_dir)
39+
.library_search_path(".")
40+
.input(cwd().join("bar.rs"))
41+
.run();
42+
}

0 commit comments

Comments
 (0)