about summary refs log tree commit diff
path: root/compiler/rustc_session/src/config
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-16 17:14:04 +0100
committerGitHub <noreply@github.com>2025-02-16 17:14:04 +0100
commitfc094a1813de0fb58cb9d4be00f5e86701000f2a (patch)
tree47307098adff66ef168f74bb3a135ab5c43b3f60 /compiler/rustc_session/src/config
parent34e789a8fb05b5f4ee9e24eff803e2dd6e2bbcc5 (diff)
parent6ec3cf9abc15368df705b65e20e7e753d565fe71 (diff)
Rollup merge of #137072 - Urgau:check-cfg-load-builtins-at-once, r=Noratrieb
Load all builtin targets at once instead of one by one in check-cfg

This PR adds a method on `rustc_target::Target` to load all the builtin targets at once, and then uses that method when constructing the `target_*` values in check-cfg instead of load loading each target one by one by their name, which requires a lookup and was more of a hack anyway.

This may give us some performance improvements as we won't need to do the lookup for the _currently_ 287 targets we have.
Diffstat (limited to 'compiler/rustc_session/src/config')
-rw-r--r--compiler/rustc_session/src/config/cfg.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs
index aa9ebdd9cea..231ca434962 100644
--- a/compiler/rustc_session/src/config/cfg.rs
+++ b/compiler/rustc_session/src/config/cfg.rs
@@ -29,7 +29,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
 use rustc_lint_defs::BuiltinLintDiag;
 use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS;
 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::config::{CrateType, FmtDebug};
@@ -432,11 +432,7 @@ impl CheckCfg {
                     panic!("unable to get all the check-cfg values buckets");
                 };
 
-                for target in TARGETS
-                    .iter()
-                    .map(|target| Target::expect_builtin(&TargetTuple::from_tuple(target)))
-                    .chain(iter::once(current_target.clone()))
-                {
+                for target in Target::builtins().chain(iter::once(current_target.clone())) {
                     values_target_abi.insert(Symbol::intern(&target.options.abi));
                     values_target_arch.insert(Symbol::intern(&target.arch));
                     values_target_endian.insert(Symbol::intern(target.options.endian.as_str()));