Skip to content

Add a flag for pretending to be a stable compiler when bisecting. #335

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

Merged
merged 2 commits into from
Feb 27, 2025
Merged
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
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -153,6 +153,13 @@ struct Opts {
)]
command_args: Vec<OsString>,

#[arg(
long,
help = "Pretend to be a stable compiler (disable features, \
report a version that looks like a stable version)"
)]
pretend_to_be_stable: bool,

#[arg(
long,
help = "Left bound for search (*without* regression). You can use \
40 changes: 28 additions & 12 deletions src/toolchains.rs
Original file line number Diff line number Diff line change
@@ -257,12 +257,7 @@ impl Toolchain {
}
(None, None) => {
let mut cmd = Command::new("cargo");
cmd.arg(&format!("+{}", self.rustup_name()));
if cfg.args.command_args.is_empty() {
cmd.arg("build");
} else {
cmd.args(&cfg.args.command_args);
}
self.set_cargo_args_and_envs(&mut cmd, cfg);
cmd
}
(Some(script), Some(timeout)) => {
@@ -277,12 +272,7 @@ impl Toolchain {
let mut cmd = Command::new("timeout");
cmd.arg(timeout.to_string());
cmd.arg("cargo");
cmd.arg(format!("+{}", self.rustup_name()));
if cfg.args.command_args.is_empty() {
cmd.arg("build");
} else {
cmd.args(&cfg.args.command_args);
}
self.set_cargo_args_and_envs(&mut cmd, cfg);
cmd
}
};
@@ -326,6 +316,32 @@ impl Toolchain {
output
}

fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) {
let rustup_name = format!("+{}", self.rustup_name());
cmd.arg(&rustup_name);
if cfg.args.command_args.is_empty() {
cmd.arg("build");
} else {
cmd.args(&cfg.args.command_args);
}
if cfg.args.pretend_to_be_stable && self.is_current_nightly() {
// Forbid using features
cmd.env(
"RUSTFLAGS",
format!(
"{} -Zallow-features=",
std::env::var("RUSTFLAGS").unwrap_or_default()
),
);
// Make rustc report a stable version string derived from the current nightly's version string.
let version = rustc_version::version_meta().unwrap().semver;
cmd.env(
"RUSTC_OVERRIDE_VERSION_STRING",
format!("{}.{}.{}", version.major, version.minor, version.patch),
);
}
}

pub(crate) fn test(&self, cfg: &Config) -> TestOutcome {
eprintln!("testing...");
let outcome = if cfg.args.prompt {
2 changes: 2 additions & 0 deletions tests/cmd/bare-h.stdout
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ Options:
--install <INSTALL> Install the given artifact
--preserve Preserve the downloaded artifacts
--preserve-target Preserve the target directory used for builds
--pretend-to-be-stable Pretend to be a stable compiler (disable features, report a version
that looks like a stable version)
--prompt Manually evaluate for regression with prompts
--regress <REGRESS> Custom regression definition [default: error] [possible values:
error, success, ice, non-ice, non-error]
4 changes: 4 additions & 0 deletions tests/cmd/bare-help.stdout
Original file line number Diff line number Diff line change
@@ -46,6 +46,10 @@ Options:
--preserve-target
Preserve the target directory used for builds

--pretend-to-be-stable
Pretend to be a stable compiler (disable features, report a version that looks like a
stable version)

--prompt
Manually evaluate for regression with prompts

2 changes: 2 additions & 0 deletions tests/cmd/h.stdout
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ Options:
--install <INSTALL> Install the given artifact
--preserve Preserve the downloaded artifacts
--preserve-target Preserve the target directory used for builds
--pretend-to-be-stable Pretend to be a stable compiler (disable features, report a version
that looks like a stable version)
--prompt Manually evaluate for regression with prompts
--regress <REGRESS> Custom regression definition [default: error] [possible values:
error, success, ice, non-ice, non-error]
4 changes: 4 additions & 0 deletions tests/cmd/help.stdout
Original file line number Diff line number Diff line change
@@ -46,6 +46,10 @@ Options:
--preserve-target
Preserve the target directory used for builds

--pretend-to-be-stable
Pretend to be a stable compiler (disable features, report a version that looks like a
stable version)

--prompt
Manually evaluate for regression with prompts