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 {ignore,needs}-{rustc,std}-debug-assertions directive support #131913

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Oct 19, 2024

Add {ignore,needs}-{rustc,std}-debug-assertions compiletest directives and retire the old {ignore,only}-debug directives. The old {ignore,only}-debug directives were ambiguous because you could have std built with debug assertions but rustc not built with debug assertions or vice versa. If we want to support the use case of controlling test run based on if rustc was built with debug assertions, then having {ignore,only}-debug will be very confusing.

cc @matthiaskrgr

Closes #123987.

r? bootstrap (or compiler tbh)

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 19, 2024
@@ -1,6 +1,7 @@
//@ compile-flags: -O -C no-prepopulate-passes
//@ only-x86_64 (to not worry about usize differing)
//@ ignore-debug: precondition checks make mem::replace not a candidate for MIR inlining
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check: we have some lint or w/e that will fail CI if someone adds a test with ignore-debug as we merge this PR?

Copy link
Member Author

@jieyouxu jieyouxu Oct 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiletest (currently) has an allowlist of known directives, I've removed ignore-debug from that so compiletest will error if someone writes ignore-debug (should be in the first commit) which will fail locally and in CI. (This is current stopgap solution before fixing how directives are handled)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will fail looking like (I know it's not super user friendly)

Testing stage1 compiletest suite=ui mode=ui (x86_64-pc-windows-msvc)
error: detected unknown compiletest test directive `only-debug` in X:\repos\rust\tests\ui\print_type_sizes\niche-filling.rs:13
errors encountered during EarlyProps parsing: X:\repos\rust\tests\ui\print_type_sizes\niche-filling.rs
thread 'main' panicked at src\tools\compiletest\src\header.rs:68:13:
errors encountered during EarlyProps parsing
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/bootstrap/src/core/build_steps/test.rs Outdated Show resolved Hide resolved
"ignore-debug",
"ignore-debug-assertions-rustc",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically here

@rustbot
Copy link
Collaborator

rustbot commented Oct 20, 2024

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@jieyouxu
Copy link
Member Author

Accompanying rustc-dev-guide PR: rust-lang/rustc-dev-guide#2101

@jieyouxu jieyouxu changed the title Add {ignore,needs}-debug-assertions-{rustc,std} directive support Add {ignore,needs}-{rustc,std}-debug-assertions directive support Oct 20, 2024
@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 20, 2024
Comment on lines -1112 to +1122
debug_assertions: Option<bool> = "debug-assertions",
rustc_debug_assertions: Option<bool> = "debug-assertions",
randomize_layout: Option<bool> = "randomize-layout",
debug_assertions_std: Option<bool> = "debug-assertions-std",
std_debug_assertions: Option<bool> = "debug-assertions-std",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change the config.toml user-facing toml name.

@jieyouxu
Copy link
Member Author

Changes since last review

  • Renamed compiletest/bootstrap fields/variables/flags to use the prefix form of {rustc,std}-debug-assertions. This does not change the config.toml option names of debug-assertions and debug-assertions-std.
  • Added a directives unit test for the {needs,ignore}-{rustc,std}-debug-assertions to check that they are recognized.
  • Updated the tests to use ignore-std-debug-assertions.

@jieyouxu
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 20, 2024
@bors

This comment was marked as resolved.

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2024
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member Author

Rebased and split compiletest/bootstrap changes into two commits, but no functional changes.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 21, 2024
@bors

This comment was marked as resolved.

…ive support

And retire the old `only-debug` directive which was ambiguous and only
for std debug assertions.
And rename local variables and field names in bootstrap from
`debug_assertions{,_std}` -> `{rustc,std}-debug-assertions` to avoid
confusion where applicable.
@jieyouxu
Copy link
Member Author

Rebased, no changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make compiletest aware whether compiler was built with debug assertions
5 participants