Skip to content

Commit 9cf759e

Browse files
authored
Unrolled build for rust-lang#125674
Rollup merge of rust-lang#125674 - Oneirical:another-day-another-test, r=jieyouxu Rewrite `symlinked-extern`, `symlinked-rlib` and `symlinked-libraries` `run-make` tests in `rmake.rs` format Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-msvc
2 parents f6b4b71 + 2ac5faa commit 9cf759e

File tree

8 files changed

+81
-36
lines changed

8 files changed

+81
-36
lines changed

src/tools/run-make-support/src/lib.rs

+28
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,34 @@ pub fn source_root() -> PathBuf {
9595
env_var("SOURCE_ROOT").into()
9696
}
9797

98+
/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
99+
#[cfg(target_family = "windows")]
100+
pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
101+
if link.as_ref().exists() {
102+
std::fs::remove_dir(link.as_ref()).unwrap();
103+
}
104+
use std::os::windows::fs;
105+
fs::symlink_file(original.as_ref(), link.as_ref()).expect(&format!(
106+
"failed to create symlink {:?} for {:?}",
107+
link.as_ref().display(),
108+
original.as_ref().display(),
109+
));
110+
}
111+
112+
/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
113+
#[cfg(target_family = "unix")]
114+
pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
115+
if link.as_ref().exists() {
116+
std::fs::remove_dir(link.as_ref()).unwrap();
117+
}
118+
use std::os::unix::fs;
119+
fs::symlink(original.as_ref(), link.as_ref()).expect(&format!(
120+
"failed to create symlink {:?} for {:?}",
121+
link.as_ref().display(),
122+
original.as_ref().display(),
123+
));
124+
}
125+
98126
/// Construct the static library name based on the platform.
99127
pub fn static_lib_name(name: &str) -> String {
100128
// See tools.mk (irrelevant lines omitted):

src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ run-make/std-core-cycle/Makefile
226226
run-make/symbol-mangling-hashed/Makefile
227227
run-make/symbol-visibility/Makefile
228228
run-make/symbols-include-type-name/Makefile
229-
run-make/symlinked-extern/Makefile
230-
run-make/symlinked-libraries/Makefile
231-
run-make/symlinked-rlib/Makefile
232229
run-make/sysroot-crates-are-unstable/Makefile
233230
run-make/target-cpu-native/Makefile
234231
run-make/target-specs/Makefile

tests/run-make/symlinked-extern/Makefile

-12
This file was deleted.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Crates that are resolved normally have their path canonicalized and all
2+
// symlinks resolved. This did not happen for paths specified
3+
// using the --extern option to rustc, which could lead to rustc thinking
4+
// that it encountered two different versions of a crate, when it's
5+
// actually the same version found through different paths.
6+
// See https://github.com/rust-lang/rust/pull/16505
7+
8+
// This test checks that --extern and symlinks together
9+
// can result in successful compilation.
10+
11+
//@ ignore-cross-compile
12+
13+
use run_make_support::{create_symlink, cwd, fs_wrapper, rustc};
14+
15+
fn main() {
16+
rustc().input("foo.rs").run();
17+
fs_wrapper::create_dir_all("other");
18+
create_symlink("libfoo.rlib", "other");
19+
rustc().input("bar.rs").library_search_path(cwd()).run();
20+
rustc().input("baz.rs").extern_("foo", "other").library_search_path(cwd()).run();
21+
}

tests/run-make/symlinked-libraries/Makefile

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// When a directory and a symlink simultaneously exist with the same name,
2+
// setting that name as the library search path should not cause rustc
3+
// to avoid looking in the symlink and cause an error. This test creates
4+
// a directory and a symlink named "other", and places the library in the symlink.
5+
// If it succeeds, the library was successfully found.
6+
// See https://github.com/rust-lang/rust/issues/12459
7+
8+
//@ ignore-cross-compile
9+
use run_make_support::{create_symlink, dynamic_lib_name, fs_wrapper, rustc};
10+
11+
fn main() {
12+
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
13+
fs_wrapper::create_dir_all("other");
14+
create_symlink(dynamic_lib_name("foo"), "other");
15+
rustc().input("bar.rs").library_search_path("other").run();
16+
}

tests/run-make/symlinked-rlib/Makefile

-10
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Rustc did not recognize libraries which were symlinked
2+
// to files having extension other than .rlib. This was fixed
3+
// in #32828. This test creates a symlink to "foo.xxx", which has
4+
// an unusual file extension, and checks that rustc can successfully
5+
// use it as an rlib library.
6+
// See https://github.com/rust-lang/rust/pull/32828
7+
8+
//@ ignore-cross-compile
9+
10+
use run_make_support::{create_symlink, cwd, rustc};
11+
12+
fn main() {
13+
rustc().input("foo.rs").crate_type("rlib").output("foo.xxx").run();
14+
create_symlink("foo.xxx", "libfoo.rlib");
15+
rustc().input("bar.rs").library_search_path(cwd()).run();
16+
}

0 commit comments

Comments
 (0)