Don't recompile the same functions for each debugging option
This reduces the amount of items in the crate by quite a lot.
This commit is contained in:
parent
85ee3d0f23
commit
a88a94e8aa
1 changed files with 566 additions and 517 deletions
|
@ -286,10 +286,26 @@ macro_rules! options {
|
|||
|
||||
pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool;
|
||||
pub const $stat: &[(&str, $setter_name, &str, &str)] =
|
||||
&[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ];
|
||||
&[ $( (stringify!($opt), crate::options::parse::$opt, $crate::options::desc::$parse, $desc) ),* ];
|
||||
|
||||
#[allow(non_upper_case_globals, dead_code)]
|
||||
mod $mod_desc {
|
||||
// Sometimes different options need to build a common structure.
|
||||
// That structure can kept in one of the options' fields, the others become dummy.
|
||||
macro_rules! redirect_field {
|
||||
($cg:ident.link_arg) => { $cg.link_args };
|
||||
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
||||
($cg:ident.$field:ident) => { $cg.$field };
|
||||
}
|
||||
|
||||
$(
|
||||
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
||||
$crate::options::parse::$parse(&mut redirect_field!(cg.$opt), v)
|
||||
}
|
||||
)*
|
||||
|
||||
) }
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
mod desc {
|
||||
pub const parse_no_flag: &str = "no value";
|
||||
pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
|
||||
pub const parse_opt_bool: &str = parse_bool;
|
||||
|
@ -306,7 +322,8 @@ macro_rules! options {
|
|||
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
||||
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
||||
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
|
||||
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
|
||||
pub const parse_sanitizers: &str =
|
||||
"comma separated list of sanitizers: `address`, `hwaddress`, `leak`, `memory` or `thread`";
|
||||
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
|
||||
pub const parse_cfguard: &str =
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
|
||||
|
@ -314,7 +331,8 @@ macro_rules! options {
|
|||
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
|
||||
pub const parse_optimization_fuel: &str = "crate=integer";
|
||||
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
|
||||
pub const parse_instrument_coverage: &str = "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
|
||||
pub const parse_instrument_coverage: &str =
|
||||
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
|
||||
pub const parse_unpretty: &str = "`string` or `string=string`";
|
||||
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
|
||||
pub const parse_lto: &str =
|
||||
|
@ -328,10 +346,8 @@ macro_rules! options {
|
|||
pub const parse_src_file_hash: &str = "either `md5` or `sha1`";
|
||||
pub const parse_relocation_model: &str =
|
||||
"one of supported relocation models (`rustc --print relocation-models`)";
|
||||
pub const parse_code_model: &str =
|
||||
"one of supported code models (`rustc --print code-models`)";
|
||||
pub const parse_tls_model: &str =
|
||||
"one of supported TLS models (`rustc --print tls-models`)";
|
||||
pub const parse_code_model: &str = "one of supported code models (`rustc --print code-models`)";
|
||||
pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)";
|
||||
pub const parse_target_feature: &str = parse_string;
|
||||
pub const parse_wasi_exec_model: &str = "either `command` or `reactor`";
|
||||
pub const parse_split_debuginfo: &str =
|
||||
|
@ -339,38 +355,33 @@ macro_rules! options {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod $mod_set {
|
||||
use super::*;
|
||||
mod parse {
|
||||
crate use super::*;
|
||||
use std::str::FromStr;
|
||||
|
||||
// Sometimes different options need to build a common structure.
|
||||
// That structure can kept in one of the options' fields, the others become dummy.
|
||||
macro_rules! redirect_field {
|
||||
($cg:ident.link_arg) => { $cg.link_args };
|
||||
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
||||
($cg:ident.$field:ident) => { $cg.$field };
|
||||
}
|
||||
|
||||
$(
|
||||
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
||||
$parse(&mut redirect_field!(cg.$opt), v)
|
||||
}
|
||||
)*
|
||||
|
||||
/// This is for boolean options that don't take a value and start with
|
||||
/// `no-`. This style of option is deprecated.
|
||||
fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
|
||||
crate fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
None => { *slot = true; true }
|
||||
None => {
|
||||
*slot = true;
|
||||
true
|
||||
}
|
||||
Some(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Use this for any boolean option that has a static default.
|
||||
fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
||||
crate fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("y") | Some("yes") | Some("on") | None => { *slot = true; true }
|
||||
Some("n") | Some("no") | Some("off") => { *slot = false; true }
|
||||
Some("y") | Some("yes") | Some("on") | None => {
|
||||
*slot = true;
|
||||
true
|
||||
}
|
||||
Some("n") | Some("no") | Some("off") => {
|
||||
*slot = false;
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -378,99 +389,131 @@ macro_rules! options {
|
|||
/// Use this for any boolean option that lacks a static default. (The
|
||||
/// actions taken when such an option is not specified will depend on
|
||||
/// other factors, such as other options, or target options.)
|
||||
fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
||||
crate fn parse_opt_bool(slot: &mut Option<bool>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("y") | Some("yes") | Some("on") | None => { *slot = Some(true); true }
|
||||
Some("n") | Some("no") | Some("off") => { *slot = Some(false); true }
|
||||
Some("y") | Some("yes") | Some("on") | None => {
|
||||
*slot = Some(true);
|
||||
true
|
||||
}
|
||||
Some("n") | Some("no") | Some("off") => {
|
||||
*slot = Some(false);
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Use this for any string option that has a static default.
|
||||
fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
||||
crate fn parse_string(slot: &mut String, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = s.to_string(); true },
|
||||
Some(s) => {
|
||||
*slot = s.to_string();
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Use this for any string option that lacks a static default.
|
||||
fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||
crate fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = Some(s.to_string()); true },
|
||||
Some(s) => {
|
||||
*slot = Some(s.to_string());
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
|
||||
crate fn parse_opt_pathbuf(slot: &mut Option<PathBuf>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = Some(PathBuf::from(s)); true },
|
||||
Some(s) => {
|
||||
*slot = Some(PathBuf::from(s));
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
||||
crate fn parse_string_push(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { slot.push(s.to_string()); true },
|
||||
Some(s) => {
|
||||
slot.push(s.to_string());
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
|
||||
crate fn parse_pathbuf_push(slot: &mut Vec<PathBuf>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { slot.push(PathBuf::from(s)); true },
|
||||
Some(s) => {
|
||||
slot.push(PathBuf::from(s));
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_list(slot: &mut Vec<String>, v: Option<&str>)
|
||||
-> bool {
|
||||
crate fn parse_list(slot: &mut Vec<String>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
slot.extend(s.split_whitespace().map(|s| s.to_string()));
|
||||
true
|
||||
},
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>)
|
||||
-> bool {
|
||||
crate fn parse_opt_comma_list(slot: &mut Option<Vec<String>>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
let v = s.split(',').map(|s| s.to_string()).collect();
|
||||
let mut v: Vec<_> = s.split(',').map(|s| s.to_string()).collect();
|
||||
v.sort_unstable();
|
||||
*slot = Some(v);
|
||||
true
|
||||
},
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
||||
crate fn parse_threads(slot: &mut usize, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| s.parse().ok()) {
|
||||
Some(0) => { *slot = ::num_cpus::get(); true },
|
||||
Some(i) => { *slot = i; true },
|
||||
None => false
|
||||
Some(0) => {
|
||||
*slot = ::num_cpus::get();
|
||||
true
|
||||
}
|
||||
Some(i) => {
|
||||
*slot = i;
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Use this for any numeric option that has a static default.
|
||||
fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
|
||||
crate fn parse_number<T: Copy + FromStr>(slot: &mut T, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| s.parse().ok()) {
|
||||
Some(i) => { *slot = i; true },
|
||||
None => false
|
||||
Some(i) => {
|
||||
*slot = i;
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Use this for any numeric option that lacks a static default.
|
||||
fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
|
||||
crate fn parse_opt_number<T: Copy + FromStr>(slot: &mut Option<T>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = s.parse().ok(); slot.is_some() }
|
||||
None => false
|
||||
Some(s) => {
|
||||
*slot = s.parse().ok();
|
||||
slot.is_some()
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
||||
crate fn parse_passes(slot: &mut Passes, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("all") => {
|
||||
*slot = Passes::All;
|
||||
|
@ -488,29 +531,27 @@ macro_rules! options {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
|
||||
crate fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("unwind") => *slot = Some(PanicStrategy::Unwind),
|
||||
Some("abort") => *slot = Some(PanicStrategy::Abort),
|
||||
_ => return false
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
||||
crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
match s.parse::<RelroLevel>() {
|
||||
Some(s) => match s.parse::<RelroLevel>() {
|
||||
Ok(level) => *slot = Some(level),
|
||||
_ => return false
|
||||
}
|
||||
_ => return false,
|
||||
},
|
||||
_ => return false
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
|
||||
crate fn parse_sanitizers(slot: &mut SanitizerSet, v: Option<&str>) -> bool {
|
||||
if let Some(v) = v {
|
||||
for s in v.split(',') {
|
||||
*slot |= match s {
|
||||
|
@ -528,16 +569,25 @@ macro_rules! options {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
|
||||
crate fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("2") | None => { *slot = 2; true }
|
||||
Some("1") => { *slot = 1; true }
|
||||
Some("0") => { *slot = 0; true }
|
||||
Some("2") | None => {
|
||||
*slot = 2;
|
||||
true
|
||||
}
|
||||
Some("1") => {
|
||||
*slot = 1;
|
||||
true
|
||||
}
|
||||
Some("0") => {
|
||||
*slot = 0;
|
||||
true
|
||||
}
|
||||
Some(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
|
||||
crate fn parse_strip(slot: &mut Strip, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("none") => *slot = Strip::None,
|
||||
Some("debuginfo") => *slot = Strip::Debuginfo,
|
||||
|
@ -547,16 +597,12 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
|
||||
crate fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() {
|
||||
CFGuard::Checks
|
||||
} else {
|
||||
CFGuard::Disabled
|
||||
};
|
||||
return true
|
||||
*slot = if bool_arg.unwrap() { CFGuard::Checks } else { CFGuard::Disabled };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,7 +615,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
|
||||
crate fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
|
||||
match v.and_then(LinkerFlavor::from_str) {
|
||||
Some(lf) => *slote = Some(lf),
|
||||
_ => return false,
|
||||
|
@ -577,22 +623,26 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
|
||||
crate fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
None => false,
|
||||
Some(s) => {
|
||||
let parts = s.split('=').collect::<Vec<_>>();
|
||||
if parts.len() != 2 { return false; }
|
||||
if parts.len() != 2 {
|
||||
return false;
|
||||
}
|
||||
let crate_name = parts[0].to_string();
|
||||
let fuel = parts[1].parse::<u64>();
|
||||
if fuel.is_err() { return false; }
|
||||
if fuel.is_err() {
|
||||
return false;
|
||||
}
|
||||
*slot = Some((crate_name, fuel.unwrap()));
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||
crate fn parse_unpretty(slot: &mut Option<String>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
None => false,
|
||||
Some(s) if s.split('=').count() <= 2 => {
|
||||
|
@ -603,16 +653,12 @@ macro_rules! options {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
|
||||
crate fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() {
|
||||
Some(MirSpanview::Statement)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
return true
|
||||
*slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,16 +679,15 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_instrument_coverage(slot: &mut Option<InstrumentCoverage>, v: Option<&str>) -> bool {
|
||||
crate fn parse_instrument_coverage(
|
||||
slot: &mut Option<InstrumentCoverage>,
|
||||
v: Option<&str>,
|
||||
) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() {
|
||||
Some(InstrumentCoverage::All)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
return true
|
||||
*slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,23 +713,25 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
|
||||
crate fn parse_treat_err_as_bug(slot: &mut Option<NonZeroUsize>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => { *slot = s.parse().ok(); slot.is_some() }
|
||||
None => { *slot = NonZeroUsize::new(1); true }
|
||||
Some(s) => {
|
||||
*slot = s.parse().ok();
|
||||
slot.is_some()
|
||||
}
|
||||
None => {
|
||||
*slot = NonZeroUsize::new(1);
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
||||
crate fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() {
|
||||
LtoCli::Yes
|
||||
} else {
|
||||
LtoCli::No
|
||||
};
|
||||
return true
|
||||
*slot = if bool_arg.unwrap() { LtoCli::Yes } else { LtoCli::No };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -697,7 +744,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
|
||||
crate fn parse_linker_plugin_lto(slot: &mut LinkerPluginLto, v: Option<&str>) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
|
@ -706,7 +753,7 @@ macro_rules! options {
|
|||
} else {
|
||||
LinkerPluginLto::Disabled
|
||||
};
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -717,7 +764,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
|
||||
crate fn parse_switch_with_opt_path(slot: &mut SwitchWithOptPath, v: Option<&str>) -> bool {
|
||||
*slot = match v {
|
||||
None => SwitchWithOptPath::Enabled(None),
|
||||
Some(path) => SwitchWithOptPath::Enabled(Some(PathBuf::from(path))),
|
||||
|
@ -725,7 +772,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
|
||||
crate fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| MergeFunctions::from_str(s).ok()) {
|
||||
Some(mergefunc) => *slot = Some(mergefunc),
|
||||
_ => return false,
|
||||
|
@ -733,7 +780,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
|
||||
crate fn parse_relocation_model(slot: &mut Option<RelocModel>, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| RelocModel::from_str(s).ok()) {
|
||||
Some(relocation_model) => *slot = Some(relocation_model),
|
||||
None if v == Some("default") => *slot = None,
|
||||
|
@ -742,7 +789,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
|
||||
crate fn parse_code_model(slot: &mut Option<CodeModel>, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| CodeModel::from_str(s).ok()) {
|
||||
Some(code_model) => *slot = Some(code_model),
|
||||
_ => return false,
|
||||
|
@ -750,7 +797,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
|
||||
crate fn parse_tls_model(slot: &mut Option<TlsModel>, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| TlsModel::from_str(s).ok()) {
|
||||
Some(tls_model) => *slot = Some(tls_model),
|
||||
_ => return false,
|
||||
|
@ -758,7 +805,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_symbol_mangling_version(
|
||||
crate fn parse_symbol_mangling_version(
|
||||
slot: &mut Option<SymbolManglingVersion>,
|
||||
v: Option<&str>,
|
||||
) -> bool {
|
||||
|
@ -770,7 +817,10 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_src_file_hash(slot: &mut Option<SourceFileHashAlgorithm>, v: Option<&str>) -> bool {
|
||||
crate fn parse_src_file_hash(
|
||||
slot: &mut Option<SourceFileHashAlgorithm>,
|
||||
v: Option<&str>,
|
||||
) -> bool {
|
||||
match v.and_then(|s| SourceFileHashAlgorithm::from_str(s).ok()) {
|
||||
Some(hash_kind) => *slot = Some(hash_kind),
|
||||
_ => return false,
|
||||
|
@ -778,7 +828,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
|
||||
crate fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => {
|
||||
if !slot.is_empty() {
|
||||
|
@ -791,7 +841,7 @@ macro_rules! options {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
|
||||
crate fn parse_wasi_exec_model(slot: &mut Option<WasiExecModel>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("command") => *slot = Some(WasiExecModel::Command),
|
||||
Some("reactor") => *slot = Some(WasiExecModel::Reactor),
|
||||
|
@ -800,7 +850,7 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
|
||||
fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
|
||||
crate fn parse_split_debuginfo(slot: &mut Option<SplitDebuginfo>, v: Option<&str>) -> bool {
|
||||
match v.and_then(|s| SplitDebuginfo::from_str(s).ok()) {
|
||||
Some(e) => *slot = Some(e),
|
||||
_ => return false,
|
||||
|
@ -808,7 +858,6 @@ macro_rules! options {
|
|||
true
|
||||
}
|
||||
}
|
||||
) }
|
||||
|
||||
options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||
build_codegen_options, "C", "codegen",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue