diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index 65ba8054f..a498a397a 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -136,6 +136,8 @@ pub struct ParsedArguments { crate_types: CrateTypes, /// If dependency info is being emitted, the name of the dep info file. dep_info: Option, + /// If gcno info is being emitted, the name of the gcno file. + gcno: Option, /// rustc says that emits .rlib for --emit=metadata /// https://github.com/rust-lang/rust/issues/54852 emit: HashSet, @@ -835,6 +837,36 @@ impl IntoArg for ArgCodegen { } } +#[derive(Clone, Debug, PartialEq)] +struct ArgUnstable { + opt: String, + value: Option, +} +impl FromArg for ArgUnstable { + fn process(arg: OsString) -> ArgParseResult { + let (opt, value) = split_os_string_arg(arg, "=")?; + Ok(ArgUnstable { opt, value }) + } +} +impl IntoArg for ArgUnstable { + fn into_arg_os_string(self) -> OsString { + let ArgUnstable { opt, value } = self; + if let Some(value) = value { + make_os_string!(opt, "=", value) + } else { + make_os_string!(opt) + } + } + fn into_arg_string(self, transformer: PathTransformerFn<'_>) -> ArgToStringResult { + let ArgUnstable { opt, value } = self; + Ok(if let Some(value) = value { + format!("{}={}", opt, value.into_arg_string(transformer)?) + } else { + opt + }) + } +} + #[derive(Clone, Debug, PartialEq)] struct ArgExtern { name: String, @@ -930,6 +962,7 @@ ArgData! { CodeGen(ArgCodegen), PassThrough(OsString), Target(ArgTarget), + Unstable(ArgUnstable), } use self::ArgData::*; @@ -968,7 +1001,7 @@ counted_array!(static ARGS: [ArgInfo; _] = [ take_arg!("-L", ArgLinkPath, CanBeSeparated, LinkPath), flag!("-V", NotCompilationFlag), take_arg!("-W", OsString, CanBeSeparated, PassThrough), - take_arg!("-Z", OsString, CanBeSeparated, PassThrough), + take_arg!("-Z", ArgUnstable, CanBeSeparated, Unstable), take_arg!("-l", ArgLinkLibrary, CanBeSeparated, LinkLibrary), take_arg!("-o", PathBuf, CanBeSeparated, TooHardPath), ]); @@ -991,6 +1024,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments = vec![]; let mut color_mode = ColorMode::Auto; let mut has_json = false; + let mut profile = false; for arg in ArgsIter::new(arguments.iter().cloned(), &ARGS[..]) { let arg = try_or_cannot_cache!(arg, "argument parse"); @@ -1057,6 +1091,12 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments (), } } + Some(Unstable(ArgUnstable { opt, value })) => match value.as_deref() { + Some("y") | Some("yes") | Some("on") | None if opt == "profile" => { + profile = true; + } + _ => (), + }, Some(Color(value)) => { // We'll just assume the last specified value wins. color_mode = match value.as_ref() { @@ -1136,7 +1176,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments CompilerArguments CompilerArguments