Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add needs-symlink directive to compiletest #126862

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-sanitizer-shadow-call-stack",
"needs-sanitizer-support",
"needs-sanitizer-thread",
"needs-symlink",
"needs-threads",
"needs-unwind",
"needs-wasmtime",
Expand Down
26 changes: 26 additions & 0 deletions src/tools/compiletest/src/header/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ pub(super) fn handle_needs(
condition: config.runner.as_ref().is_some_and(|r| r.contains("wasmtime")),
ignore_reason: "ignored when wasmtime runner is not available",
},
Need {
name: "needs-symlink",
condition: cache.symlinks,
ignore_reason: "ignored if symlinks are unavailable",
},
];

let (name, comment) = match ln.split_once([':', ' ']) {
Expand Down Expand Up @@ -209,6 +214,7 @@ pub(super) struct CachedNeedsConditions {
xray: bool,
rust_lld: bool,
dlltool: bool,
symlinks: bool,
}

impl CachedNeedsConditions {
Expand Down Expand Up @@ -253,6 +259,7 @@ impl CachedNeedsConditions {
.exists(),

dlltool: find_dlltool(&config),
symlinks: has_symlinks(),
}
}
}
Expand All @@ -279,3 +286,22 @@ fn find_dlltool(config: &Config) -> bool {
};
dlltool_found
}

#[cfg(windows)]
fn has_symlinks() -> bool {
if std::env::var_os("CI").is_some() {
return true;
}
let link = std::env::temp_dir().join("RUST_COMPILETEST_SYMLINK_CHECK");
if std::os::windows::fs::symlink_file("DOES NOT EXIST", &link).is_ok() {
std::fs::remove_file(&link).unwrap();
true
} else {
false
}
}

#[cfg(not(windows))]
fn has_symlinks() -> bool {
true
}
1 change: 1 addition & 0 deletions tests/run-make/symlinked-extern/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// can result in successful compilation.

//@ ignore-cross-compile
//@ needs-symlink

use run_make_support::{create_symlink, cwd, fs_wrapper, rustc};

Expand Down
1 change: 1 addition & 0 deletions tests/run-make/symlinked-libraries/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// See https://github.com/rust-lang/rust/issues/12459

//@ ignore-cross-compile
//@ needs-symlink

use run_make_support::{create_symlink, dynamic_lib_name, fs_wrapper, rustc};

Expand Down
1 change: 1 addition & 0 deletions tests/run-make/symlinked-rlib/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// See https://github.com/rust-lang/rust/pull/32828

//@ ignore-cross-compile
//@ needs-symlink

use run_make_support::{create_symlink, cwd, rustc};

Expand Down
Loading