Load all builtin targets at once instead of one by one
This should give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
This commit is contained in:
parent
3f33b30e19
commit
6ec3cf9abc
2 changed files with 15 additions and 6 deletions
|
@ -29,7 +29,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_lint_defs::BuiltinLintDiag;
|
use rustc_lint_defs::BuiltinLintDiag;
|
||||||
use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS;
|
use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS;
|
||||||
use rustc_span::{Symbol, sym};
|
use rustc_span::{Symbol, sym};
|
||||||
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, TARGETS, Target, TargetTuple};
|
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target};
|
||||||
|
|
||||||
use crate::Session;
|
use crate::Session;
|
||||||
use crate::config::{CrateType, FmtDebug};
|
use crate::config::{CrateType, FmtDebug};
|
||||||
|
@ -426,11 +426,7 @@ impl CheckCfg {
|
||||||
panic!("unable to get all the check-cfg values buckets");
|
panic!("unable to get all the check-cfg values buckets");
|
||||||
};
|
};
|
||||||
|
|
||||||
for target in TARGETS
|
for target in Target::builtins().chain(iter::once(current_target.clone())) {
|
||||||
.iter()
|
|
||||||
.map(|target| Target::expect_builtin(&TargetTuple::from_tuple(target)))
|
|
||||||
.chain(iter::once(current_target.clone()))
|
|
||||||
{
|
|
||||||
values_target_abi.insert(Symbol::intern(&target.options.abi));
|
values_target_abi.insert(Symbol::intern(&target.options.abi));
|
||||||
values_target_arch.insert(Symbol::intern(&target.arch));
|
values_target_arch.insert(Symbol::intern(&target.arch));
|
||||||
values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));
|
values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));
|
||||||
|
|
|
@ -1662,6 +1662,14 @@ macro_rules! supported_targets {
|
||||||
Some(t)
|
Some(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_all_builtins() -> impl Iterator<Item = Target> {
|
||||||
|
[
|
||||||
|
$( targets::$module::target, )+
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.map(|f| f())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
// Cannot put this into a separate file without duplication, make an exception.
|
// Cannot put this into a separate file without duplication, make an exception.
|
||||||
|
@ -3360,6 +3368,11 @@ impl Target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Load all built-in targets
|
||||||
|
pub fn builtins() -> impl Iterator<Item = Target> {
|
||||||
|
load_all_builtins()
|
||||||
|
}
|
||||||
|
|
||||||
/// Search for a JSON file specifying the given target tuple.
|
/// Search for a JSON file specifying the given target tuple.
|
||||||
///
|
///
|
||||||
/// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the
|
/// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue