Skip to content

Commit

Permalink
Unrolled build for rust-lang#131470
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#131470 - EnzymeAD:enzyme-testinfra2, r=jieyouxu

add test infra to explicitely test rustc with autodiff/enzyme disabled

I assume this is not what you want for now, but I'll update the PR once I understand how the ignore- directives work.

To summarize the situation, we want a feature gate test where we don't enable the autodiff feature using `#![feature(autodiff)]`. There are two situations.
1) We have a rustc which was build without autodiff support (current default): It gives one error about the feature being needed and one error about this rustc version being build without autodiff support.
2) We have a rustc which was build with autodiff support (i.e. for now a custom build): It gives one error about the feature being needed.

We have a `//`````@needs-enzyme`````` directive which we can use in revisions for the second case.
However, we have no way to specify that needs-enzyme implies that the second error should not be seen.
This ads a way of passing the following test:
```
//@ revisions: has_support no_support
//`````@[has_support]````` needs-enzyme
//`````@[no_support]````` needs-enzyme-disabled

#![crate_type = "lib"]

#[autodiff(dfoo, Reverse)]
//[has_support]~^ ERROR use of unstable library feature 'autodiff' [E0658]
//[no_support]~^^ ERROR use of unstable library feature 'autodiff' [E0658]
//[no_support]~| ERROR this rustc version does not support autodiff
fn foo() {}
```
Cherry picking this PR to my frontend pr makes the test above pass in both configurations (enzyme=true/false in config.toml).
I'm open to other changes that make this testcase pass.

r? `````@jieyouxu`````

Tracking:

- rust-lang#124509
  • Loading branch information
rust-timer authored Oct 10, 2024
2 parents d0141af + b12dc20 commit 3d0e994
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-eabi",
"ignore-emscripten",
"ignore-endian-big",
"ignore-enzyme",
"ignore-freebsd",
"ignore-fuchsia",
"ignore-gdb",
Expand Down
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/header/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ pub(super) fn parse_cfg_name_directive<'a>(
message: "when the target vendor is Apple"
}

condition! {
name: "enzyme",
condition: config.has_enzyme,
message: "when rustc is built with LLVM Enzyme"
}

// 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
// treat the "dev" channel as the "nightly" channel when processing the directive.
Expand Down

0 comments on commit 3d0e994

Please sign in to comment.