Skip to content

Commit 3e8ec15

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 3e8ec15

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-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,34 @@
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 not
6+
//! under the same directory tree. After this was fixed in #13903, this test checks that compilation
7+
//! succeeds through use of the symlink.
8+
9+
//@ ignore-cross-compile
10+
11+
use run_make_support::{bare_rustc, cwd, path, rfs, rust_lib_name};
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+
// NOTE: `bare_rustc` is used because it does not introduce an implicit `-L .` library search
20+
// flag.
21+
bare_rustc().input("foo.rs").output(actual_lib_dir.join(rust_lib_name("foo"))).run();
22+
23+
rfs::symlink_file(
24+
actual_lib_dir.join(rust_lib_name("foo")),
25+
symlink_lib_dir.join(rust_lib_name("foo")),
26+
);
27+
28+
// Make rustc's $CWD be in the directory containing the symlink-to-lib.
29+
bare_rustc()
30+
.current_dir(&symlink_lib_dir)
31+
.library_search_path(".")
32+
.input(cwd().join("bar.rs"))
33+
.run();
34+
}

0 commit comments

Comments
 (0)