From 988fdd55efa29d086c9200f50357dc96c278f330 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 04:17:21 +0100 Subject: [PATCH 01/11] Build out rustc version detection infrastructure --- src/main.rs | 1 + src/rustc_version.rs | 95 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/rustc_version.rs diff --git a/src/main.rs b/src/main.rs index 8e4f640..a0e21e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ mod templates; mod options; mod project; mod utils; +mod rustc_version; static FUZZ_TARGETS_DIR_OLD: &str = "fuzzers"; static FUZZ_TARGETS_DIR: &str = "fuzz_targets"; diff --git a/src/rustc_version.rs b/src/rustc_version.rs new file mode 100644 index 0000000..5e8116d --- /dev/null +++ b/src/rustc_version.rs @@ -0,0 +1,95 @@ +//! Rust compiler version detection + +use std::{cmp::Ordering, process::Command, str::FromStr}; + +/// Checks if the compiler currently in use is nightly, or `RUSTC_BOOTSTRAP` is set to get nightly features on stable +pub fn is_nightly(version_string: &str) -> bool { + version_string.contains("-nightly ") || std::env::var_os("RUSTC_BOOTSTRAP").is_some() +} + +/// Returns the output of `rustc --version` +pub fn rust_version_string() -> String { + // The path to rustc can be specified via an environment variable: + // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads + let rustc_path = std::env::var_os("RUSTC").unwrap_or("rustc".into()); + let raw_output = Command::new(rustc_path) + .arg("--version") + .output() + .expect("Failed to invoke rustc! Is it in your $PATH?") + .stdout; + String::from_utf8(raw_output).expect("`rustc --version` returned non-text output somehow") +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd)] +pub struct RustVersion { + pub major: u32, + pub minor: u32, + // we don't care about the patch version and it's a bit of a pain to parse +} + +impl Ord for RustVersion { + fn cmp(&self, other: &Self) -> Ordering { + match self.major.cmp(&other.major) { + Ordering::Equal => self.minor.cmp(&other.minor), + other => other, + } + } +} + +impl FromStr for RustVersion { + type Err = &'static str; + + fn from_str(s: &str) -> Result { + let s = s.strip_prefix("rustc ").ok_or("Rust version string does not start with 'rustc'!")?; + let mut iter = s.split('.'); + let major: u32 = iter.next().ok_or("No major version found in `rustc --version` output!")?.parse().map_err(|_| "Failed to parse major version in `rustc --version` output as a number!")?; + let minor: u32 = iter.next().ok_or("No minor version found in `rustc --version` output!")?.parse().map_err(|_| "Failed to parse minor version in `rustc --version` output as a number!")?; + Ok(RustVersion {major, minor}) + } +} + +/// Checks whether the compiler supports sanitizers on stable channel. +/// Such compilers (even nightly) do not support `-Zsanitizer` flag, +/// and require a different combination of flags even on nightly. +/// +/// Stabilization PR with more info: +impl RustVersion { + fn has_sanitizers_on_stable(version: &Self) -> bool { + // TODO: the release that stabilizes sanitizers is not currently known. + // This value is a PLACEHOLDER. + let release_that_stabilized_sanitizers = RustVersion { + major: 1, + minor: 85, + }; + version >= &release_that_stabilized_sanitizers + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parsing_stable() { + let version_string = "rustc 1.78.0 (9b00956e5 2024-04-29)"; + let result = RustVersion::from_str(version_string).unwrap(); + assert_eq!(result, RustVersion { major: 1, minor: 78}); + assert!(!is_nightly(version_string)) + } + + #[test] + fn test_parsing_nightly() { + let version_string = "rustc 1.81.0-nightly (d7f6ebace 2024-06-16)"; + let result = RustVersion::from_str(version_string).unwrap(); + assert_eq!(result, RustVersion { major: 1, minor: 81}); + assert!(is_nightly(version_string)) + } + + #[test] + fn test_parsing_future_stable() { + let version_string = "rustc 2.356.1 (deadfaced 2029-04-01)"; + let result = RustVersion::from_str(version_string).unwrap(); + assert_eq!(result, RustVersion { major: 2, minor: 356}); + assert!(!is_nightly(version_string)) + } +} \ No newline at end of file From 5f24537966d0427ddff35e9b75317117ad02a123 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 04:17:41 +0100 Subject: [PATCH 02/11] cargo fmt --- src/main.rs | 2 +- src/rustc_version.rs | 50 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index a0e21e9..4243d96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,8 @@ use clap::Parser; mod templates; mod options; mod project; -mod utils; mod rustc_version; +mod utils; static FUZZ_TARGETS_DIR_OLD: &str = "fuzzers"; static FUZZ_TARGETS_DIR: &str = "fuzz_targets"; diff --git a/src/rustc_version.rs b/src/rustc_version.rs index 5e8116d..e5daa79 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -40,18 +40,32 @@ impl FromStr for RustVersion { type Err = &'static str; fn from_str(s: &str) -> Result { - let s = s.strip_prefix("rustc ").ok_or("Rust version string does not start with 'rustc'!")?; + let s = s + .strip_prefix("rustc ") + .ok_or("Rust version string does not start with 'rustc'!")?; let mut iter = s.split('.'); - let major: u32 = iter.next().ok_or("No major version found in `rustc --version` output!")?.parse().map_err(|_| "Failed to parse major version in `rustc --version` output as a number!")?; - let minor: u32 = iter.next().ok_or("No minor version found in `rustc --version` output!")?.parse().map_err(|_| "Failed to parse minor version in `rustc --version` output as a number!")?; - Ok(RustVersion {major, minor}) + let major: u32 = iter + .next() + .ok_or("No major version found in `rustc --version` output!")? + .parse() + .map_err(|_| { + "Failed to parse major version in `rustc --version` output as a number!" + })?; + let minor: u32 = iter + .next() + .ok_or("No minor version found in `rustc --version` output!")? + .parse() + .map_err(|_| { + "Failed to parse minor version in `rustc --version` output as a number!" + })?; + Ok(RustVersion { major, minor }) } } /// Checks whether the compiler supports sanitizers on stable channel. /// Such compilers (even nightly) do not support `-Zsanitizer` flag, /// and require a different combination of flags even on nightly. -/// +/// /// Stabilization PR with more info: impl RustVersion { fn has_sanitizers_on_stable(version: &Self) -> bool { @@ -73,7 +87,13 @@ mod tests { fn test_parsing_stable() { let version_string = "rustc 1.78.0 (9b00956e5 2024-04-29)"; let result = RustVersion::from_str(version_string).unwrap(); - assert_eq!(result, RustVersion { major: 1, minor: 78}); + assert_eq!( + result, + RustVersion { + major: 1, + minor: 78 + } + ); assert!(!is_nightly(version_string)) } @@ -81,7 +101,13 @@ mod tests { fn test_parsing_nightly() { let version_string = "rustc 1.81.0-nightly (d7f6ebace 2024-06-16)"; let result = RustVersion::from_str(version_string).unwrap(); - assert_eq!(result, RustVersion { major: 1, minor: 81}); + assert_eq!( + result, + RustVersion { + major: 1, + minor: 81 + } + ); assert!(is_nightly(version_string)) } @@ -89,7 +115,13 @@ mod tests { fn test_parsing_future_stable() { let version_string = "rustc 2.356.1 (deadfaced 2029-04-01)"; let result = RustVersion::from_str(version_string).unwrap(); - assert_eq!(result, RustVersion { major: 2, minor: 356}); + assert_eq!( + result, + RustVersion { + major: 2, + minor: 356 + } + ); assert!(!is_nightly(version_string)) } -} \ No newline at end of file +} From 7c5ee322177834fb480194d46a62c36b96979bf8 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 04:32:26 +0100 Subject: [PATCH 03/11] Use anyhow for error handling in rustc version detection --- src/rustc_version.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rustc_version.rs b/src/rustc_version.rs index e5daa79..a481f65 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -2,22 +2,24 @@ use std::{cmp::Ordering, process::Command, str::FromStr}; +use anyhow::Context; + /// Checks if the compiler currently in use is nightly, or `RUSTC_BOOTSTRAP` is set to get nightly features on stable pub fn is_nightly(version_string: &str) -> bool { version_string.contains("-nightly ") || std::env::var_os("RUSTC_BOOTSTRAP").is_some() } /// Returns the output of `rustc --version` -pub fn rust_version_string() -> String { +pub fn rust_version_string() -> anyhow::Result { // The path to rustc can be specified via an environment variable: // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads let rustc_path = std::env::var_os("RUSTC").unwrap_or("rustc".into()); let raw_output = Command::new(rustc_path) .arg("--version") .output() - .expect("Failed to invoke rustc! Is it in your $PATH?") + .context("Failed to invoke rustc! Is it in your $PATH?")? .stdout; - String::from_utf8(raw_output).expect("`rustc --version` returned non-text output somehow") + String::from_utf8(raw_output).context("`rustc --version` returned non-text output somehow") } #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd)] From a93a462d8454615c1a7cce3c131bf2065266e33f Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 04:59:28 +0100 Subject: [PATCH 04/11] Actually wire up all the sanitizer flag handling machinery --- src/project.rs | 44 ++++++++++++++++++++++++++++++++++---------- src/rustc_version.rs | 16 ++++++++++++++-- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/project.rs b/src/project.rs index 3bcc37e..364a7ef 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,4 +1,5 @@ use crate::options::{self, BuildMode, BuildOptions, Sanitizer}; +use crate::rustc_version::{is_nightly, rust_version_string, sanitizer_flag, RustVersion}; use crate::utils::default_target; use anyhow::{anyhow, bail, Context, Result}; use cargo_metadata::MetadataCommand; @@ -6,6 +7,7 @@ use std::collections::HashSet; use std::io::Read; use std::io::Write; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::{ env, ffi, fs, process::{Command, Stdio}, @@ -187,17 +189,39 @@ impl FuzzProject { rustflags.push_str(" -Cinstrument-coverage"); } - match build.sanitizer { - Sanitizer::None => {} - Sanitizer::Memory => { - // Memory sanitizer requires more flags to function than others: - // https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html#memorysanitizer - rustflags.push_str(" -Zsanitizer=memory -Zsanitizer-memory-track-origins") + if !matches!(build.sanitizer, Sanitizer::None) { + // Select the appropriate sanitizer flag for the given rustc version: + // either -Zsanitizer or -Csanitizer. + let rust_version_string = rust_version_string()?; + let rust_version = + RustVersion::from_str(&rust_version_string).map_err(|e| anyhow::anyhow!(e))?; + let sanitizer_flag = sanitizer_flag(&rust_version)?; + + // Set rustc CLI arguments for the chosen sanitizer + match build.sanitizer { + Sanitizer::None => {} // should be unreachable + Sanitizer::Memory => { + // Memory sanitizer requires more flags to function than others: + // https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html#memorysanitizer + rustflags.push_str(&format!( + " {sanitizer_flag}=memory {sanitizer_flag}-memory-track-origins" + )) + } + _ => rustflags.push_str(&format!( + " {sanitizer_flag}={sanitizer}", + sanitizer = build.sanitizer + )), + } + + // Not all sanitizers are stabilized on all platforms. + // It is infeasible to keep up this code to date with the list. + // So we just set `-Zunstable-options`` required for some sanitizers + // whenever we're on nightly on a recent enough compiler, + // and let the compiler show an error message + // if the user tries to enable a sanitizer not supported on their stable compiler. + if is_nightly(&rust_version_string) && rust_version.has_sanitizers_on_stable() { + rustflags.push_str(" -Zunstable-options") } - _ => rustflags.push_str(&format!( - " -Zsanitizer={sanitizer}", - sanitizer = build.sanitizer - )), } if build.careful_mode { diff --git a/src/rustc_version.rs b/src/rustc_version.rs index a481f65..5e8d18c 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -22,6 +22,18 @@ pub fn rust_version_string() -> anyhow::Result { String::from_utf8(raw_output).context("`rustc --version` returned non-text output somehow") } +/// Returns either "-Zsanitizer" or "-Csanitizer" depending on the compiler version. +/// +/// Stabilization of sanitizers has removed the "-Zsanitizer" flag, even on nightly, +/// so we have to choose the appropriate flag for the compiler version. +/// More info: +pub fn sanitizer_flag(version: &RustVersion) -> anyhow::Result<&'static str> { + match version.has_sanitizers_on_stable() { + true => Ok("-Csanitizer"), + false => Ok("-Zsanitizer"), + } +} + #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd)] pub struct RustVersion { pub major: u32, @@ -70,14 +82,14 @@ impl FromStr for RustVersion { /// /// Stabilization PR with more info: impl RustVersion { - fn has_sanitizers_on_stable(version: &Self) -> bool { + pub fn has_sanitizers_on_stable(&self) -> bool { // TODO: the release that stabilizes sanitizers is not currently known. // This value is a PLACEHOLDER. let release_that_stabilized_sanitizers = RustVersion { major: 1, minor: 85, }; - version >= &release_that_stabilized_sanitizers + self >= &release_that_stabilized_sanitizers } } From 555620729ba7c2ac4086dfa0e7521129b4d65731 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 05:14:45 +0100 Subject: [PATCH 05/11] minor stuff --- src/project.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/project.rs b/src/project.rs index 364a7ef..b8379f3 100644 --- a/src/project.rs +++ b/src/project.rs @@ -199,7 +199,7 @@ impl FuzzProject { // Set rustc CLI arguments for the chosen sanitizer match build.sanitizer { - Sanitizer::None => {} // should be unreachable + Sanitizer::None => {} // needs no flags Sanitizer::Memory => { // Memory sanitizer requires more flags to function than others: // https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html#memorysanitizer @@ -207,10 +207,7 @@ impl FuzzProject { " {sanitizer_flag}=memory {sanitizer_flag}-memory-track-origins" )) } - _ => rustflags.push_str(&format!( - " {sanitizer_flag}={sanitizer}", - sanitizer = build.sanitizer - )), + _ => rustflags.push_str(&format!(" {sanitizer_flag}={}", build.sanitizer)), } // Not all sanitizers are stabilized on all platforms. From 3eecd3d8383cb98164621f57dee1dab6f683d3f5 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 06:16:07 +0100 Subject: [PATCH 06/11] Fix -Zsanitizer-memory-track-origins flag which was not changed --- src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project.rs b/src/project.rs index b8379f3..66422f1 100644 --- a/src/project.rs +++ b/src/project.rs @@ -204,7 +204,7 @@ impl FuzzProject { // Memory sanitizer requires more flags to function than others: // https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html#memorysanitizer rustflags.push_str(&format!( - " {sanitizer_flag}=memory {sanitizer_flag}-memory-track-origins" + " {sanitizer_flag}=memory -Zsanitizer-memory-track-origins" )) } _ => rustflags.push_str(&format!(" {sanitizer_flag}={}", build.sanitizer)), From 92ebfeef6ac9057b92841eb6da3363a7288da411 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Fri, 12 Jul 2024 22:51:51 +0100 Subject: [PATCH 07/11] Inline sanitizer flag selection now that it's infallible --- src/project.rs | 7 +++++-- src/rustc_version.rs | 12 ------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/project.rs b/src/project.rs index 66422f1..b622d76 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,5 @@ use crate::options::{self, BuildMode, BuildOptions, Sanitizer}; -use crate::rustc_version::{is_nightly, rust_version_string, sanitizer_flag, RustVersion}; +use crate::rustc_version::{is_nightly, rust_version_string, RustVersion}; use crate::utils::default_target; use anyhow::{anyhow, bail, Context, Result}; use cargo_metadata::MetadataCommand; @@ -195,7 +195,10 @@ impl FuzzProject { let rust_version_string = rust_version_string()?; let rust_version = RustVersion::from_str(&rust_version_string).map_err(|e| anyhow::anyhow!(e))?; - let sanitizer_flag = sanitizer_flag(&rust_version)?; + let sanitizer_flag = match rust_version.has_sanitizers_on_stable() { + true => "-Csanitizer", + false => "-Zsanitizer", + }; // Set rustc CLI arguments for the chosen sanitizer match build.sanitizer { diff --git a/src/rustc_version.rs b/src/rustc_version.rs index 5e8d18c..8d9bc70 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -22,18 +22,6 @@ pub fn rust_version_string() -> anyhow::Result { String::from_utf8(raw_output).context("`rustc --version` returned non-text output somehow") } -/// Returns either "-Zsanitizer" or "-Csanitizer" depending on the compiler version. -/// -/// Stabilization of sanitizers has removed the "-Zsanitizer" flag, even on nightly, -/// so we have to choose the appropriate flag for the compiler version. -/// More info: -pub fn sanitizer_flag(version: &RustVersion) -> anyhow::Result<&'static str> { - match version.has_sanitizers_on_stable() { - true => Ok("-Csanitizer"), - false => Ok("-Zsanitizer"), - } -} - #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd)] pub struct RustVersion { pub major: u32, From 50f66f7de29e826dcd1628ec425d6756401a3039 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 16 Jul 2024 01:23:29 +0100 Subject: [PATCH 08/11] Better encapsulate compiler version discovery --- src/project.rs | 9 +++------ src/rustc_version.rs | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/project.rs b/src/project.rs index b622d76..2c10c5f 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,5 @@ use crate::options::{self, BuildMode, BuildOptions, Sanitizer}; -use crate::rustc_version::{is_nightly, rust_version_string, RustVersion}; +use crate::rustc_version::RustVersion; use crate::utils::default_target; use anyhow::{anyhow, bail, Context, Result}; use cargo_metadata::MetadataCommand; @@ -7,7 +7,6 @@ use std::collections::HashSet; use std::io::Read; use std::io::Write; use std::path::{Path, PathBuf}; -use std::str::FromStr; use std::{ env, ffi, fs, process::{Command, Stdio}, @@ -192,9 +191,7 @@ impl FuzzProject { if !matches!(build.sanitizer, Sanitizer::None) { // Select the appropriate sanitizer flag for the given rustc version: // either -Zsanitizer or -Csanitizer. - let rust_version_string = rust_version_string()?; - let rust_version = - RustVersion::from_str(&rust_version_string).map_err(|e| anyhow::anyhow!(e))?; + let rust_version = RustVersion::discover()?; let sanitizer_flag = match rust_version.has_sanitizers_on_stable() { true => "-Csanitizer", false => "-Zsanitizer", @@ -219,7 +216,7 @@ impl FuzzProject { // whenever we're on nightly on a recent enough compiler, // and let the compiler show an error message // if the user tries to enable a sanitizer not supported on their stable compiler. - if is_nightly(&rust_version_string) && rust_version.has_sanitizers_on_stable() { + if rust_version.nightly && rust_version.has_sanitizers_on_stable() { rustflags.push_str(" -Zunstable-options") } } diff --git a/src/rustc_version.rs b/src/rustc_version.rs index 8d9bc70..4a4f85e 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -5,12 +5,12 @@ use std::{cmp::Ordering, process::Command, str::FromStr}; use anyhow::Context; /// Checks if the compiler currently in use is nightly, or `RUSTC_BOOTSTRAP` is set to get nightly features on stable -pub fn is_nightly(version_string: &str) -> bool { +fn is_nightly(version_string: &str) -> bool { version_string.contains("-nightly ") || std::env::var_os("RUSTC_BOOTSTRAP").is_some() } /// Returns the output of `rustc --version` -pub fn rust_version_string() -> anyhow::Result { +fn rust_version_string() -> anyhow::Result { // The path to rustc can be specified via an environment variable: // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads let rustc_path = std::env::var_os("RUSTC").unwrap_or("rustc".into()); @@ -27,6 +27,7 @@ pub struct RustVersion { pub major: u32, pub minor: u32, // we don't care about the patch version and it's a bit of a pain to parse + pub nightly: bool, } impl Ord for RustVersion { @@ -38,6 +39,14 @@ impl Ord for RustVersion { } } +impl RustVersion { + pub fn discover() -> anyhow::Result { + let version_string = rust_version_string()?; + let me = Self::from_str(&version_string).map_err(|e| anyhow::anyhow!(e))?; + Ok(me) + } +} + impl FromStr for RustVersion { type Err = &'static str; @@ -60,7 +69,12 @@ impl FromStr for RustVersion { .map_err(|_| { "Failed to parse minor version in `rustc --version` output as a number!" })?; - Ok(RustVersion { major, minor }) + let nightly = is_nightly(s); + Ok(RustVersion { + major, + minor, + nightly, + }) } } @@ -76,6 +90,7 @@ impl RustVersion { let release_that_stabilized_sanitizers = RustVersion { major: 1, minor: 85, + nightly: false, }; self >= &release_that_stabilized_sanitizers } @@ -93,10 +108,10 @@ mod tests { result, RustVersion { major: 1, - minor: 78 + minor: 78, + nightly: false, } ); - assert!(!is_nightly(version_string)) } #[test] @@ -107,10 +122,10 @@ mod tests { result, RustVersion { major: 1, - minor: 81 + minor: 81, + nightly: true, } ); - assert!(is_nightly(version_string)) } #[test] @@ -121,9 +136,9 @@ mod tests { result, RustVersion { major: 2, - minor: 356 + minor: 356, + nightly: false, } ); - assert!(!is_nightly(version_string)) } } From 230c3ccff475af349899d45c48ad1dec3f9dae59 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 16 Jul 2024 01:24:19 +0100 Subject: [PATCH 09/11] Set placeholder version values to u32::MAX to make the PR mergeable immediately --- src/rustc_version.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rustc_version.rs b/src/rustc_version.rs index 4a4f85e..c92863d 100644 --- a/src/rustc_version.rs +++ b/src/rustc_version.rs @@ -88,8 +88,8 @@ impl RustVersion { // TODO: the release that stabilizes sanitizers is not currently known. // This value is a PLACEHOLDER. let release_that_stabilized_sanitizers = RustVersion { - major: 1, - minor: 85, + major: u32::MAX, + minor: u32::MAX, nightly: false, }; self >= &release_that_stabilized_sanitizers From e57a70b56eb50b60dc5999ad3cc71c94f2a90ef6 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 16 Jul 2024 01:26:46 +0100 Subject: [PATCH 10/11] Fix typo in comment --- src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project.rs b/src/project.rs index 2c10c5f..b646e92 100644 --- a/src/project.rs +++ b/src/project.rs @@ -212,7 +212,7 @@ impl FuzzProject { // Not all sanitizers are stabilized on all platforms. // It is infeasible to keep up this code to date with the list. - // So we just set `-Zunstable-options`` required for some sanitizers + // So we just set `-Zunstable-options` required for some sanitizers // whenever we're on nightly on a recent enough compiler, // and let the compiler show an error message // if the user tries to enable a sanitizer not supported on their stable compiler. From a52c0e59317f42c7a98ded1b79439ed9fcd2e538 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 16 Jul 2024 01:29:14 +0100 Subject: [PATCH 11/11] Less verbose comment --- src/project.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/project.rs b/src/project.rs index b646e92..799a42b 100644 --- a/src/project.rs +++ b/src/project.rs @@ -189,8 +189,7 @@ impl FuzzProject { } if !matches!(build.sanitizer, Sanitizer::None) { - // Select the appropriate sanitizer flag for the given rustc version: - // either -Zsanitizer or -Csanitizer. + // Select the appropriate sanitizer flag for the given rustc version let rust_version = RustVersion::discover()?; let sanitizer_flag = match rust_version.has_sanitizers_on_stable() { true => "-Csanitizer",