Skip to content

Commit 2b33ce9

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 2b33ce9

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-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,32 @@
1+
//! Regression test for [rustc doesn't handle relative symlinks to libraries
2+
//! #13890](https://github.com/rust-lang/rust/issues/13890).
3+
//!
4+
//! The rust compiler searches by default for libraries in its current directory, but used to have
5+
//! difficulty following symlinks leading to required libraries if the real ones were located
6+
//! elsewhere. After this was fixed in #13903, this test checks that compilation succeeds through
7+
//! use of the symlink.
8+
9+
//@ ignore-cross-compile
10+
11+
use run_make_support::{bare_rustc, cwd, path, rfs, rust_lib_name, rustc};
12+
13+
fn main() {
14+
let actual_lib_dir = path("actual_lib_dir");
15+
let symlink_lib_dir = path("symlink_lib_dir");
16+
rfs::create_dir_all(&actual_lib_dir);
17+
rfs::create_dir_all(&symlink_lib_dir);
18+
19+
bare_rustc().input("foo.rs").output(actual_lib_dir.join(rust_lib_name("foo"))).run();
20+
21+
rfs::symlink_file(
22+
actual_lib_dir.join(rust_lib_name("foo")),
23+
symlink_lib_dir.join(rust_lib_name("foo")),
24+
);
25+
26+
// Make rustc's $CWD be in the directory containing the symlink-to-lib.
27+
bare_rustc()
28+
.current_dir(&symlink_lib_dir)
29+
.library_search_path(".")
30+
.input(cwd().join("bar.rs"))
31+
.run();
32+
}

0 commit comments

Comments
 (0)