Skip to content
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
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,10 @@ Please disable assertions with `rust.debug-assertions = false`.
cmd.arg("--has-enzyme");
}

if builder.build.config.llvm_offload {
cmd.arg("--has-offload");
}

if builder.config.cmd.bless() {
cmd.arg("--bless");
}
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ settings:
that this directive can be overriden with the `--bypass-ignore-backends=[BACKEND]` command line
flag.
- `needs-backends` — only runs the test if current codegen backend is listed.
- `needs-offload` — ignores if our LLVM backend was not built with offload support.
- `needs-enzyme` — ignores if our Enzyme submodule was not built.

The following directives will check LLVM support:

Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ pub struct Config {
/// Whether to run `enzyme` autodiff tests.
pub has_enzyme: bool,

/// Whether to run `offload` autodiff tests.
pub has_offload: bool,

/// The current Rust channel info.
///
/// FIXME: treat this more carefully; "stable", "beta" and "nightly" are definitely valid, but
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions {
// FIXME(Zalathar): Support all known binary formats, not just ELF?
builder.cond("elf", current.binary_format == "elf", "when the target binary format is ELF");
builder.cond("enzyme", config.has_enzyme, "when rustc is built with LLVM Enzyme");
builder.cond("offload", config.has_offload, "when rustc is built with LLVM Offload");

// Technically the locally built compiler uses the "dev" channel rather than the "nightly"
// channel, even though most people don't know or won't care about it. To avoid confusion, we
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-git-hash",
"needs-llvm-components",
"needs-llvm-zstd",
"needs-offload",
"needs-profiler-runtime",
"needs-relocation-model-pic",
"needs-run-enabled",
Expand Down
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/directives/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ pub(super) fn handle_needs(
condition: config.has_enzyme && config.default_codegen_backend.is_llvm(),
ignore_reason: "ignored when LLVM Enzyme is disabled or LLVM is not the default codegen backend",
},
Need {
name: "needs-offload",
condition: config.has_offload && config.default_codegen_backend.is_llvm(),
ignore_reason: "ignored when LLVM Offload is disabled or LLVM is not the default codegen backend",
},
Need {
name: "needs-run-enabled",
condition: config.run_enabled(),
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ fn parse_config(args: Vec<String>) -> Config {
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
.optflag("", "ignored", "run tests marked as ignored")
.optflag("", "has-enzyme", "run tests that require enzyme")
.optflag("", "has-offload", "run tests that require offload")
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
.optflag("", "with-std-remap-debuginfo", "whether std was built with remapping")
Expand Down Expand Up @@ -299,6 +300,7 @@ fn parse_config(args: Vec<String>) -> Config {
let with_std_remap_debuginfo = matches.opt_present("with-std-remap-debuginfo");
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
let has_enzyme = matches.opt_present("has-enzyme");
let has_offload = matches.opt_present("has-offload");
let filters = if mode == TestMode::RunMake {
matches
.free
Expand Down Expand Up @@ -444,6 +446,7 @@ fn parse_config(args: Vec<String>) -> Config {
compare_mode,
rustfix_coverage: matches.opt_present("rustfix-coverage"),
has_enzyme,
has_offload,
channel: matches.opt_str("channel").unwrap(),
git_hash: matches.opt_present("git-hash"),
edition: matches.opt_str("edition").as_deref().map(parse_edition),
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/rustdoc_gui_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config {
compare_mode: Default::default(),
rustfix_coverage: Default::default(),
has_enzyme: Default::default(),
has_offload: Default::default(),
channel: Default::default(),
git_hash: Default::default(),
cc: Default::default(),
Expand Down
Loading