Skip to content

Commit 1e0a952

Browse files
committed
port symlinked-libraries to rmake
1 parent 5b4b92a commit 1e0a952

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ pub fn source_path() -> PathBuf {
7777
}
7878

7979
/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
80+
#[cfg(target_family = "windows")]
8081
pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
81-
if is_windows() {
82-
use std::os::windows::fs;
83-
fs::symlink_file(original, link).unwrap();
84-
} else {
85-
use std::os::unix::fs;
86-
fs::symlink(original, link).unwrap();
87-
}
82+
use std::os::windows::fs;
83+
fs::symlink_file(original, link).unwrap();
84+
}
85+
86+
/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
87+
#[cfg(target_family = "unix")]
88+
pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
89+
use std::os::unix::fs;
90+
fs::symlink(original, link)
91+
.expect(&format!("failed to create symlink {} for {}", link, original));
8892
}
8993

9094
/// Construct the static library name based on the platform.

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ run-make/suspicious-library/Makefile
252252
run-make/symbol-mangling-hashed/Makefile
253253
run-make/symbol-visibility/Makefile
254254
run-make/symbols-include-type-name/Makefile
255-
run-make/symlinked-libraries/Makefile
256255
run-make/sysroot-crates-are-unstable/Makefile
257256
run-make/target-cpu-native/Makefile
258257
run-make/target-specs/Makefile

tests/run-make/symlinked-libraries/Makefile

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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, rustc, tmp_dir};
10+
use std::fs;
11+
12+
fn main() {
13+
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
14+
fs::create_dir_all(tmp_dir().join("other")).unwrap();
15+
create_symlink(dynamic_lib("foo"), tmp_dir().join("other"));
16+
rustc().input("bar.rs").library_search_path(tmp_dir().join("other")).run();
17+
}

0 commit comments

Comments
 (0)