Skip to content

Commit

Permalink
compiletest: implement needs-subprocess directive
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Jan 23, 2025
1 parent cf577f3 commit 339616b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,17 @@ impl Config {
git_merge_commit_email: &self.git_merge_commit_email,
}
}

pub fn has_subprocess_support(&self) -> bool {
// FIXME(#135928): compiletest is always a **host** tool. Building and running an
// capability detection executable against the **target** is not trivial. The short term
// solution here is to hard-code some targets to allow/deny, unfortunately.

let unsupported_target = self.target_cfg().env == "sgx"
|| matches!(self.target_cfg().arch.as_str(), "wasm32" | "wasm64")
|| self.target_cfg().os == "emscripten";
!unsupported_target
}
}

/// Known widths of `target_has_atomic`.
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-sanitizer-support",
"needs-sanitizer-thread",
"needs-std-debug-assertions",
"needs-subprocess",
"needs-symlink",
"needs-target-has-atomic",
"needs-threads",
Expand Down
8 changes: 8 additions & 0 deletions src/tools/compiletest/src/header/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ pub(super) fn handle_needs(
condition: config.has_threads(),
ignore_reason: "ignored on targets without threading support",
},
Need {
name: "needs-subprocess",
condition: config.has_subprocess_support(),
ignore_reason: "ignored on targets without subprocess support",
},
Need {
name: "needs-unwind",
condition: config.can_unwind(),
Expand Down Expand Up @@ -351,6 +356,9 @@ fn find_dlltool(config: &Config) -> bool {
dlltool_found
}

// FIXME(#135928): this is actually not quite right because this detection is run on the **host**.
// This however still helps the case of windows -> windows local development in case symlinks are
// not available.
#[cfg(windows)]
fn has_symlinks() -> bool {
if std::env::var_os("CI").is_some() {
Expand Down

0 comments on commit 339616b

Please sign in to comment.