From 11502b12b50e135a37a33c29f67fb899f61c33d9 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 25 Apr 2024 09:22:28 +0000 Subject: [PATCH 1/2] Deduplicate cargo invocation logic --- src/toolchains.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/toolchains.rs b/src/toolchains.rs index 2baa591..f8a4bf1 100644 --- a/src/toolchains.rs +++ b/src/toolchains.rs @@ -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,15 @@ impl Toolchain { output } + fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) { + cmd.arg(&format!("+{}", self.rustup_name())); + if cfg.args.command_args.is_empty() { + cmd.arg("build"); + } else { + cmd.args(&cfg.args.command_args); + } + } + pub(crate) fn test(&self, cfg: &Config) -> TestOutcome { eprintln!("testing..."); let outcome = if cfg.args.prompt { From 700f876087652cd8f2ce0882e8f9615353f70568 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 25 Apr 2024 09:39:22 +0000 Subject: [PATCH 2/2] Use the new RUSTC_OVERRIDE_VERSION_STRING env var Add a flag for pretending to be a stable compiler when bisecting. --- src/main.rs | 7 +++++++ src/toolchains.rs | 19 ++++++++++++++++++- tests/cmd/bare-h.stdout | 2 ++ tests/cmd/bare-help.stdout | 4 ++++ tests/cmd/h.stdout | 2 ++ tests/cmd/help.stdout | 4 ++++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0af618e..65cab99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -153,6 +153,13 @@ struct Opts { )] command_args: Vec, + #[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 \ diff --git a/src/toolchains.rs b/src/toolchains.rs index f8a4bf1..3586f9e 100644 --- a/src/toolchains.rs +++ b/src/toolchains.rs @@ -317,12 +317,29 @@ impl Toolchain { } fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) { - cmd.arg(&format!("+{}", self.rustup_name())); + 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 { diff --git a/tests/cmd/bare-h.stdout b/tests/cmd/bare-h.stdout index c450078..fee81f4 100644 --- a/tests/cmd/bare-h.stdout +++ b/tests/cmd/bare-h.stdout @@ -19,6 +19,8 @@ Options: --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 Custom regression definition [default: error] [possible values: error, success, ice, non-ice, non-error] diff --git a/tests/cmd/bare-help.stdout b/tests/cmd/bare-help.stdout index ead0a74..53ef27a 100644 --- a/tests/cmd/bare-help.stdout +++ b/tests/cmd/bare-help.stdout @@ -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 diff --git a/tests/cmd/h.stdout b/tests/cmd/h.stdout index c450078..fee81f4 100644 --- a/tests/cmd/h.stdout +++ b/tests/cmd/h.stdout @@ -19,6 +19,8 @@ Options: --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 Custom regression definition [default: error] [possible values: error, success, ice, non-ice, non-error] diff --git a/tests/cmd/help.stdout b/tests/cmd/help.stdout index ead0a74..53ef27a 100644 --- a/tests/cmd/help.stdout +++ b/tests/cmd/help.stdout @@ -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