Skip to content

Commit 19907e6

Browse files
authored
Rollup merge of #150427 - ZuseZ4:offload-testinfra, r=jieyouxu
add has_offload/needs-offload to the test infra unblocks: #150426 Mostly copied from #131044 lmk if some of these changes should land separately? r? jieyouxu
2 parents 9de01a8 + 6e0b610 commit 19907e6

File tree

8 files changed

+20
-0
lines changed

8 files changed

+20
-0
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,10 @@ Please disable assertions with `rust.debug-assertions = false`.
20642064
cmd.arg("--has-enzyme");
20652065
}
20662066

2067+
if builder.build.config.llvm_offload {
2068+
cmd.arg("--has-offload");
2069+
}
2070+
20672071
if builder.config.cmd.bless() {
20682072
cmd.arg("--bless");
20692073
}

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ settings:
213213
that this directive can be overriden with the `--bypass-ignore-backends=[BACKEND]` command line
214214
flag.
215215
- `needs-backends` — only runs the test if current codegen backend is listed.
216+
- `needs-offload` — ignores if our LLVM backend was not built with offload support.
217+
- `needs-enzyme` — ignores if our Enzyme submodule was not built.
216218

217219
The following directives will check LLVM support:
218220

src/tools/compiletest/src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ pub struct Config {
625625
/// Whether to run `enzyme` autodiff tests.
626626
pub has_enzyme: bool,
627627

628+
/// Whether to run `offload` autodiff tests.
629+
pub has_offload: bool,
630+
628631
/// The current Rust channel info.
629632
///
630633
/// FIXME: treat this more carefully; "stable", "beta" and "nightly" are definitely valid, but

src/tools/compiletest/src/directives/cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions {
164164
// FIXME(Zalathar): Support all known binary formats, not just ELF?
165165
builder.cond("elf", current.binary_format == "elf", "when the target binary format is ELF");
166166
builder.cond("enzyme", config.has_enzyme, "when rustc is built with LLVM Enzyme");
167+
builder.cond("offload", config.has_offload, "when rustc is built with LLVM Offload");
167168

168169
// Technically the locally built compiler uses the "dev" channel rather than the "nightly"
169170
// channel, even though most people don't know or won't care about it. To avoid confusion, we

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
165165
"needs-git-hash",
166166
"needs-llvm-components",
167167
"needs-llvm-zstd",
168+
"needs-offload",
168169
"needs-profiler-runtime",
169170
"needs-relocation-model-pic",
170171
"needs-run-enabled",

src/tools/compiletest/src/directives/needs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ pub(super) fn handle_needs(
9191
condition: config.has_enzyme && config.default_codegen_backend.is_llvm(),
9292
ignore_reason: "ignored when LLVM Enzyme is disabled or LLVM is not the default codegen backend",
9393
},
94+
Need {
95+
name: "needs-offload",
96+
condition: config.has_offload && config.default_codegen_backend.is_llvm(),
97+
ignore_reason: "ignored when LLVM Offload is disabled or LLVM is not the default codegen backend",
98+
},
9499
Need {
95100
name: "needs-run-enabled",
96101
condition: config.run_enabled(),

src/tools/compiletest/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ fn parse_config(args: Vec<String>) -> Config {
104104
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
105105
.optflag("", "ignored", "run tests marked as ignored")
106106
.optflag("", "has-enzyme", "run tests that require enzyme")
107+
.optflag("", "has-offload", "run tests that require offload")
107108
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
108109
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
109110
.optflag("", "with-std-remap-debuginfo", "whether std was built with remapping")
@@ -299,6 +300,7 @@ fn parse_config(args: Vec<String>) -> Config {
299300
let with_std_remap_debuginfo = matches.opt_present("with-std-remap-debuginfo");
300301
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
301302
let has_enzyme = matches.opt_present("has-enzyme");
303+
let has_offload = matches.opt_present("has-offload");
302304
let filters = if mode == TestMode::RunMake {
303305
matches
304306
.free
@@ -444,6 +446,7 @@ fn parse_config(args: Vec<String>) -> Config {
444446
compare_mode,
445447
rustfix_coverage: matches.opt_present("rustfix-coverage"),
446448
has_enzyme,
449+
has_offload,
447450
channel: matches.opt_str("channel").unwrap(),
448451
git_hash: matches.opt_present("git-hash"),
449452
edition: matches.opt_str("edition").as_deref().map(parse_edition),

src/tools/compiletest/src/rustdoc_gui_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config {
113113
compare_mode: Default::default(),
114114
rustfix_coverage: Default::default(),
115115
has_enzyme: Default::default(),
116+
has_offload: Default::default(),
116117
channel: Default::default(),
117118
git_hash: Default::default(),
118119
cc: Default::default(),

0 commit comments

Comments
 (0)