Rollup merge of #134251 - bjorn3:various_cleanups2, r=oli-obk
A bunch of cleanups (part 2) Just like https://github.com/rust-lang/rust/pull/133567 these were all found while looking at the respective code, but are not blocking any other changes I want to make in the short term.
This commit is contained in:
commit
87bbbcd1bb
18 changed files with 43 additions and 71 deletions
|
@ -3507,7 +3507,6 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"either",
|
"either",
|
||||||
"itertools",
|
"itertools",
|
||||||
"jobserver",
|
|
||||||
"libc",
|
"libc",
|
||||||
"object 0.36.5",
|
"object 0.36.5",
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::sync::{Arc, Condvar, Mutex};
|
use std::sync::{Arc, Condvar, Mutex};
|
||||||
|
|
||||||
use jobserver::HelperThread;
|
use rustc_data_structures::jobserver::{self, HelperThread};
|
||||||
use rustc_errors::DiagCtxtHandle;
|
use rustc_errors::DiagCtxtHandle;
|
||||||
use rustc_session::Session;
|
|
||||||
|
|
||||||
// FIXME don't panic when a worker thread panics
|
// FIXME don't panic when a worker thread panics
|
||||||
|
|
||||||
|
@ -14,14 +13,13 @@ pub(super) struct ConcurrencyLimiter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConcurrencyLimiter {
|
impl ConcurrencyLimiter {
|
||||||
pub(super) fn new(sess: &Session, pending_jobs: usize) -> Self {
|
pub(super) fn new(pending_jobs: usize) -> Self {
|
||||||
let state = Arc::new(Mutex::new(state::ConcurrencyLimiterState::new(pending_jobs)));
|
let state = Arc::new(Mutex::new(state::ConcurrencyLimiterState::new(pending_jobs)));
|
||||||
let available_token_condvar = Arc::new(Condvar::new());
|
let available_token_condvar = Arc::new(Condvar::new());
|
||||||
|
|
||||||
let state_helper = state.clone();
|
let state_helper = state.clone();
|
||||||
let available_token_condvar_helper = available_token_condvar.clone();
|
let available_token_condvar_helper = available_token_condvar.clone();
|
||||||
let helper_thread = sess
|
let helper_thread = jobserver::client()
|
||||||
.jobserver
|
|
||||||
.clone()
|
.clone()
|
||||||
.into_helper_thread(move |token| {
|
.into_helper_thread(move |token| {
|
||||||
let mut state = state_helper.lock().unwrap();
|
let mut state = state_helper.lock().unwrap();
|
||||||
|
@ -113,7 +111,7 @@ impl Drop for ConcurrencyLimiterToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod state {
|
mod state {
|
||||||
use jobserver::Acquired;
|
use rustc_data_structures::jobserver::Acquired;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(super) struct ConcurrencyLimiterState {
|
pub(super) struct ConcurrencyLimiterState {
|
||||||
|
|
|
@ -679,7 +679,7 @@ pub(crate) fn run_aot(
|
||||||
metadata_module: None,
|
metadata_module: None,
|
||||||
metadata,
|
metadata,
|
||||||
crate_info: CrateInfo::new(tcx, target_cpu),
|
crate_info: CrateInfo::new(tcx, target_cpu),
|
||||||
concurrency_limiter: ConcurrencyLimiter::new(tcx.sess, 0),
|
concurrency_limiter: ConcurrencyLimiter::new(0),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ pub(crate) fn run_aot(
|
||||||
CguReuse::PreLto | CguReuse::PostLto => false,
|
CguReuse::PreLto | CguReuse::PostLto => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
let concurrency_limiter = IntoDynSyncSend(ConcurrencyLimiter::new(tcx.sess, todo_cgus.len()));
|
let concurrency_limiter = IntoDynSyncSend(ConcurrencyLimiter::new(todo_cgus.len()));
|
||||||
|
|
||||||
let modules = tcx.sess.time("codegen mono items", || {
|
let modules = tcx.sess.time("codegen mono items", || {
|
||||||
let mut modules: Vec<_> = par_map(todo_cgus, |(_, cgu)| {
|
let mut modules: Vec<_> = par_map(todo_cgus, |(_, cgu)| {
|
||||||
|
|
|
@ -287,12 +287,7 @@ fn dep_symbol_lookup_fn(
|
||||||
|
|
||||||
let mut dylib_paths = Vec::new();
|
let mut dylib_paths = Vec::new();
|
||||||
|
|
||||||
let data = &crate_info
|
let data = &crate_info.dependency_formats[&rustc_session::config::CrateType::Executable].1;
|
||||||
.dependency_formats
|
|
||||||
.iter()
|
|
||||||
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
|
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
// `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to
|
// `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to
|
||||||
// get a postorder which ensures that all dependencies of a dylib are loaded before the dylib
|
// get a postorder which ensures that all dependencies of a dylib are loaded before the dylib
|
||||||
// itself. This helps the dynamic linker to find dylibs not in the regular dynamic library
|
// itself. This helps the dynamic linker to find dylibs not in the regular dynamic library
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#![warn(unused_lifetimes)]
|
#![warn(unused_lifetimes)]
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
|
|
||||||
extern crate jobserver;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_abi;
|
extern crate rustc_abi;
|
||||||
|
|
|
@ -11,7 +11,6 @@ bitflags = "2.4.1"
|
||||||
cc = "1.1.23"
|
cc = "1.1.23"
|
||||||
either = "1.5.0"
|
either = "1.5.0"
|
||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
jobserver = "0.1.28"
|
|
||||||
pathdiff = "0.2.0"
|
pathdiff = "0.2.0"
|
||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
rustc_abi = { path = "../rustc_abi" }
|
rustc_abi = { path = "../rustc_abi" }
|
||||||
|
|
|
@ -236,7 +236,13 @@ pub fn each_linked_rlib(
|
||||||
) -> Result<(), errors::LinkRlibError> {
|
) -> Result<(), errors::LinkRlibError> {
|
||||||
let crates = info.used_crates.iter();
|
let crates = info.used_crates.iter();
|
||||||
|
|
||||||
let fmts = if crate_type.is_none() {
|
let fmts = if let Some(crate_type) = crate_type {
|
||||||
|
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
|
||||||
|
return Err(errors::LinkRlibError::MissingFormat);
|
||||||
|
};
|
||||||
|
|
||||||
|
fmts
|
||||||
|
} else {
|
||||||
for combination in info.dependency_formats.iter().combinations(2) {
|
for combination in info.dependency_formats.iter().combinations(2) {
|
||||||
let (ty1, list1) = &combination[0];
|
let (ty1, list1) = &combination[0];
|
||||||
let (ty2, list2) = &combination[1];
|
let (ty2, list2) = &combination[1];
|
||||||
|
@ -252,18 +258,7 @@ pub fn each_linked_rlib(
|
||||||
if info.dependency_formats.is_empty() {
|
if info.dependency_formats.is_empty() {
|
||||||
return Err(errors::LinkRlibError::MissingFormat);
|
return Err(errors::LinkRlibError::MissingFormat);
|
||||||
}
|
}
|
||||||
&info.dependency_formats[0].1
|
info.dependency_formats.first().unwrap().1
|
||||||
} else {
|
|
||||||
let fmts = info
|
|
||||||
.dependency_formats
|
|
||||||
.iter()
|
|
||||||
.find_map(|&(ty, ref list)| if Some(ty) == crate_type { Some(list) } else { None });
|
|
||||||
|
|
||||||
let Some(fmts) = fmts else {
|
|
||||||
return Err(errors::LinkRlibError::MissingFormat);
|
|
||||||
};
|
|
||||||
|
|
||||||
fmts
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for &cnum in crates {
|
for &cnum in crates {
|
||||||
|
@ -624,8 +619,7 @@ fn link_staticlib(
|
||||||
let fmts = codegen_results
|
let fmts = codegen_results
|
||||||
.crate_info
|
.crate_info
|
||||||
.dependency_formats
|
.dependency_formats
|
||||||
.iter()
|
.get(&CrateType::Staticlib)
|
||||||
.find_map(|&(ty, ref list)| if ty == CrateType::Staticlib { Some(list) } else { None })
|
|
||||||
.expect("no dependency formats for staticlib");
|
.expect("no dependency formats for staticlib");
|
||||||
|
|
||||||
let mut all_rust_dylibs = vec![];
|
let mut all_rust_dylibs = vec![];
|
||||||
|
@ -2355,11 +2349,10 @@ fn linker_with_args(
|
||||||
// they are used within inlined functions or instantiated generic functions. We do this *after*
|
// they are used within inlined functions or instantiated generic functions. We do this *after*
|
||||||
// handling the raw-dylib symbols in the current crate to make sure that those are chosen first
|
// handling the raw-dylib symbols in the current crate to make sure that those are chosen first
|
||||||
// by the linker.
|
// by the linker.
|
||||||
let (_, dependency_linkage) = codegen_results
|
let dependency_linkage = codegen_results
|
||||||
.crate_info
|
.crate_info
|
||||||
.dependency_formats
|
.dependency_formats
|
||||||
.iter()
|
.get(&crate_type)
|
||||||
.find(|(ty, _)| *ty == crate_type)
|
|
||||||
.expect("failed to find crate type in dependency format list");
|
.expect("failed to find crate type in dependency format list");
|
||||||
|
|
||||||
// We sort the libraries below
|
// We sort the libraries below
|
||||||
|
@ -2738,11 +2731,10 @@ fn add_upstream_rust_crates(
|
||||||
// Linking to a rlib involves just passing it to the linker (the linker
|
// Linking to a rlib involves just passing it to the linker (the linker
|
||||||
// will slurp up the object files inside), and linking to a dynamic library
|
// will slurp up the object files inside), and linking to a dynamic library
|
||||||
// involves just passing the right -l flag.
|
// involves just passing the right -l flag.
|
||||||
let (_, data) = codegen_results
|
let data = codegen_results
|
||||||
.crate_info
|
.crate_info
|
||||||
.dependency_formats
|
.dependency_formats
|
||||||
.iter()
|
.get(&crate_type)
|
||||||
.find(|(ty, _)| *ty == crate_type)
|
|
||||||
.expect("failed to find crate type in dependency format list");
|
.expect("failed to find crate type in dependency format list");
|
||||||
|
|
||||||
if sess.target.is_like_aix {
|
if sess.target.is_like_aix {
|
||||||
|
|
|
@ -1749,7 +1749,7 @@ fn for_each_exported_symbols_include_dep<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
let formats = tcx.dependency_formats(());
|
let formats = tcx.dependency_formats(());
|
||||||
let deps = formats.iter().find_map(|(t, list)| (*t == crate_type).then_some(list)).unwrap();
|
let deps = &formats[&crate_type];
|
||||||
|
|
||||||
for (index, dep_format) in deps.iter().enumerate() {
|
for (index, dep_format) in deps.iter().enumerate() {
|
||||||
let cnum = CrateNum::new(index + 1);
|
let cnum = CrateNum::new(index + 1);
|
||||||
|
|
|
@ -6,9 +6,9 @@ use std::sync::Arc;
|
||||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use std::{fs, io, mem, str, thread};
|
use std::{fs, io, mem, str, thread};
|
||||||
|
|
||||||
use jobserver::{Acquired, Client};
|
|
||||||
use rustc_ast::attr;
|
use rustc_ast::attr;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||||
|
use rustc_data_structures::jobserver::{self, Acquired};
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
||||||
use rustc_errors::emitter::Emitter;
|
use rustc_errors::emitter::Emitter;
|
||||||
|
@ -456,7 +456,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
||||||
metadata_module: Option<CompiledModule>,
|
metadata_module: Option<CompiledModule>,
|
||||||
) -> OngoingCodegen<B> {
|
) -> OngoingCodegen<B> {
|
||||||
let (coordinator_send, coordinator_receive) = channel();
|
let (coordinator_send, coordinator_receive) = channel();
|
||||||
let sess = tcx.sess;
|
|
||||||
|
|
||||||
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
|
let crate_attrs = tcx.hir().attrs(rustc_hir::CRATE_HIR_ID);
|
||||||
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
|
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
|
||||||
|
@ -477,7 +476,6 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
|
||||||
shared_emitter,
|
shared_emitter,
|
||||||
codegen_worker_send,
|
codegen_worker_send,
|
||||||
coordinator_receive,
|
coordinator_receive,
|
||||||
sess.jobserver.clone(),
|
|
||||||
Arc::new(regular_config),
|
Arc::new(regular_config),
|
||||||
Arc::new(metadata_config),
|
Arc::new(metadata_config),
|
||||||
Arc::new(allocator_config),
|
Arc::new(allocator_config),
|
||||||
|
@ -1093,7 +1091,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
shared_emitter: SharedEmitter,
|
shared_emitter: SharedEmitter,
|
||||||
codegen_worker_send: Sender<CguMessage>,
|
codegen_worker_send: Sender<CguMessage>,
|
||||||
coordinator_receive: Receiver<Box<dyn Any + Send>>,
|
coordinator_receive: Receiver<Box<dyn Any + Send>>,
|
||||||
jobserver: Client,
|
|
||||||
regular_config: Arc<ModuleConfig>,
|
regular_config: Arc<ModuleConfig>,
|
||||||
metadata_config: Arc<ModuleConfig>,
|
metadata_config: Arc<ModuleConfig>,
|
||||||
allocator_config: Arc<ModuleConfig>,
|
allocator_config: Arc<ModuleConfig>,
|
||||||
|
@ -1145,7 +1142,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
// get tokens on `coordinator_receive` which will
|
// get tokens on `coordinator_receive` which will
|
||||||
// get managed in the main loop below.
|
// get managed in the main loop below.
|
||||||
let coordinator_send2 = coordinator_send.clone();
|
let coordinator_send2 = coordinator_send.clone();
|
||||||
let helper = jobserver
|
let helper = jobserver::client()
|
||||||
.into_helper_thread(move |token| {
|
.into_helper_thread(move |token| {
|
||||||
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
|
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::{LazyLock, OnceLock};
|
use std::sync::{LazyLock, OnceLock};
|
||||||
|
|
||||||
pub use jobserver_crate::Client;
|
pub use jobserver_crate::{Acquired, Client, HelperThread};
|
||||||
use jobserver_crate::{FromEnv, FromEnvErrorKind};
|
use jobserver_crate::{FromEnv, FromEnvErrorKind};
|
||||||
|
|
||||||
// We can only call `from_env_ext` once per process
|
// We can only call `from_env_ext` once per process
|
||||||
|
|
|
@ -347,6 +347,8 @@ fn run_compiler(
|
||||||
|
|
||||||
callbacks.config(&mut config);
|
callbacks.config(&mut config);
|
||||||
|
|
||||||
|
let registered_lints = config.register_lints.is_some();
|
||||||
|
|
||||||
interface::run_compiler(config, |compiler| {
|
interface::run_compiler(config, |compiler| {
|
||||||
let sess = &compiler.sess;
|
let sess = &compiler.sess;
|
||||||
let codegen_backend = &*compiler.codegen_backend;
|
let codegen_backend = &*compiler.codegen_backend;
|
||||||
|
@ -362,7 +364,7 @@ fn run_compiler(
|
||||||
// `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
|
// `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
|
||||||
// it must happen after lints are registered, during session creation.
|
// it must happen after lints are registered, during session creation.
|
||||||
if sess.opts.describe_lints {
|
if sess.opts.describe_lints {
|
||||||
describe_lints(sess);
|
describe_lints(sess, registered_lints);
|
||||||
return early_exit();
|
return early_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,7 +982,7 @@ the command line flag directly.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write to stdout lint command options, together with a list of all available lints
|
/// Write to stdout lint command options, together with a list of all available lints
|
||||||
pub fn describe_lints(sess: &Session) {
|
pub fn describe_lints(sess: &Session, registered_lints: bool) {
|
||||||
safe_println!(
|
safe_println!(
|
||||||
"
|
"
|
||||||
Available lint options:
|
Available lint options:
|
||||||
|
@ -1084,7 +1086,7 @@ Available lint options:
|
||||||
|
|
||||||
print_lint_groups(builtin_groups, true);
|
print_lint_groups(builtin_groups, true);
|
||||||
|
|
||||||
match (sess.registered_lints, loaded.len(), loaded_groups.len()) {
|
match (registered_lints, loaded.len(), loaded_groups.len()) {
|
||||||
(false, 0, _) | (false, _, 0) => {
|
(false, 0, _) | (false, _, 0) => {
|
||||||
safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
|
safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,7 +371,6 @@ pub(crate) fn initialize_checked_jobserver(early_dcx: &EarlyDiagCtxt) {
|
||||||
|
|
||||||
// JUSTIFICATION: before session exists, only config
|
// JUSTIFICATION: before session exists, only config
|
||||||
#[allow(rustc::bad_opt_access)]
|
#[allow(rustc::bad_opt_access)]
|
||||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
|
||||||
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
||||||
trace!("run_compiler");
|
trace!("run_compiler");
|
||||||
|
|
||||||
|
@ -425,7 +424,11 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||||
config.opts.unstable_opts.translate_directionality_markers,
|
config.opts.unstable_opts.translate_directionality_markers,
|
||||||
) {
|
) {
|
||||||
Ok(bundle) => bundle,
|
Ok(bundle) => bundle,
|
||||||
Err(e) => early_dcx.early_fatal(format!("failed to load fluent bundle: {e}")),
|
Err(e) => {
|
||||||
|
// We can't translate anything if we failed to load translations
|
||||||
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
|
early_dcx.early_fatal(format!("failed to load fluent bundle: {e}"))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut locale_resources = config.locale_resources;
|
let mut locale_resources = config.locale_resources;
|
||||||
|
@ -479,7 +482,6 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||||
let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints());
|
let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints());
|
||||||
if let Some(register_lints) = config.register_lints.as_deref() {
|
if let Some(register_lints) = config.register_lints.as_deref() {
|
||||||
register_lints(&sess, &mut lint_store);
|
register_lints(&sess, &mut lint_store);
|
||||||
sess.registered_lints = true;
|
|
||||||
}
|
}
|
||||||
sess.lint_store = Some(Lrc::new(lint_store));
|
sess.lint_store = Some(Lrc::new(lint_store));
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
|
||||||
verify_ok(tcx, &linkage);
|
verify_ok(tcx, &linkage);
|
||||||
(ty, linkage)
|
(ty, linkage)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||||
|
|
|
@ -2161,10 +2161,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
fn encode_dylib_dependency_formats(&mut self) -> LazyArray<Option<LinkagePreference>> {
|
fn encode_dylib_dependency_formats(&mut self) -> LazyArray<Option<LinkagePreference>> {
|
||||||
empty_proc_macro!(self);
|
empty_proc_macro!(self);
|
||||||
let formats = self.tcx.dependency_formats(());
|
let formats = self.tcx.dependency_formats(());
|
||||||
for (ty, arr) in formats.iter() {
|
if let Some(arr) = formats.get(&CrateType::Dylib) {
|
||||||
if *ty != CrateType::Dylib {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return self.lazy_array(arr.iter().map(|slot| match *slot {
|
return self.lazy_array(arr.iter().map(|slot| match *slot {
|
||||||
Linkage::NotLinked | Linkage::IncludedFromDylib => None,
|
Linkage::NotLinked | Linkage::IncludedFromDylib => None,
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
// FIXME: move this file to rustc_metadata::dependency_format, but
|
// FIXME: move this file to rustc_metadata::dependency_format, but
|
||||||
// this will introduce circular dependency between rustc_metadata and rustc_middle
|
// this will introduce circular dependency between rustc_metadata and rustc_middle
|
||||||
|
|
||||||
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_macros::{Decodable, Encodable, HashStable};
|
use rustc_macros::{Decodable, Encodable, HashStable};
|
||||||
use rustc_session::config::CrateType;
|
use rustc_session::config::CrateType;
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ pub type DependencyList = Vec<Linkage>;
|
||||||
/// A mapping of all required dependencies for a particular flavor of output.
|
/// A mapping of all required dependencies for a particular flavor of output.
|
||||||
///
|
///
|
||||||
/// This is local to the tcx, and is generally relevant to one session.
|
/// This is local to the tcx, and is generally relevant to one session.
|
||||||
pub type Dependencies = Vec<(CrateType, DependencyList)>;
|
pub type Dependencies = FxIndexMap<CrateType, DependencyList>;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug, HashStable, Encodable, Decodable)]
|
#[derive(Copy, Clone, PartialEq, Debug, HashStable, Encodable, Decodable)]
|
||||||
pub enum Linkage {
|
pub enum Linkage {
|
||||||
|
|
|
@ -8,7 +8,6 @@ use std::{env, fmt, io};
|
||||||
|
|
||||||
use rustc_data_structures::flock;
|
use rustc_data_structures::flock;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||||
use rustc_data_structures::jobserver::{self, Client};
|
|
||||||
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
|
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
|
||||||
use rustc_data_structures::sync::{
|
use rustc_data_structures::sync::{
|
||||||
DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
|
DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
|
||||||
|
@ -154,16 +153,9 @@ pub struct Session {
|
||||||
/// Data about code being compiled, gathered during compilation.
|
/// Data about code being compiled, gathered during compilation.
|
||||||
pub code_stats: CodeStats,
|
pub code_stats: CodeStats,
|
||||||
|
|
||||||
/// Loaded up early on in the initialization of this `Session` to avoid
|
|
||||||
/// false positives about a job server in our environment.
|
|
||||||
pub jobserver: Client,
|
|
||||||
|
|
||||||
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
|
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
|
||||||
pub lint_store: Option<Lrc<dyn LintStoreMarker>>,
|
pub lint_store: Option<Lrc<dyn LintStoreMarker>>,
|
||||||
|
|
||||||
/// Should be set if any lints are registered in `lint_store`.
|
|
||||||
pub registered_lints: bool,
|
|
||||||
|
|
||||||
/// Cap lint level specified by a driver specifically.
|
/// Cap lint level specified by a driver specifically.
|
||||||
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||||
|
|
||||||
|
@ -1072,9 +1064,7 @@ pub fn build_session(
|
||||||
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
|
incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
|
||||||
prof,
|
prof,
|
||||||
code_stats: Default::default(),
|
code_stats: Default::default(),
|
||||||
jobserver: jobserver::client(),
|
|
||||||
lint_store: None,
|
lint_store: None,
|
||||||
registered_lints: false,
|
|
||||||
driver_lint_caps,
|
driver_lint_caps,
|
||||||
ctfe_backtrace,
|
ctfe_backtrace,
|
||||||
miri_unleashed_features: Lock::new(Default::default()),
|
miri_unleashed_features: Lock::new(Default::default()),
|
||||||
|
|
|
@ -846,11 +846,13 @@ fn main_args(
|
||||||
|
|
||||||
let config = core::create_config(input, options, &render_options, using_internal_features);
|
let config = core::create_config(input, options, &render_options, using_internal_features);
|
||||||
|
|
||||||
|
let registered_lints = config.register_lints.is_some();
|
||||||
|
|
||||||
interface::run_compiler(config, |compiler| {
|
interface::run_compiler(config, |compiler| {
|
||||||
let sess = &compiler.sess;
|
let sess = &compiler.sess;
|
||||||
|
|
||||||
if sess.opts.describe_lints {
|
if sess.opts.describe_lints {
|
||||||
rustc_driver::describe_lints(sess);
|
rustc_driver::describe_lints(sess, registered_lints);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,9 @@ pub fn iter_exported_symbols<'tcx>(
|
||||||
let dependency_formats = tcx.dependency_formats(());
|
let dependency_formats = tcx.dependency_formats(());
|
||||||
// Find the dependencies of the executable we are running.
|
// Find the dependencies of the executable we are running.
|
||||||
let dependency_format = dependency_formats
|
let dependency_format = dependency_formats
|
||||||
.iter()
|
.get(&CrateType::Executable)
|
||||||
.find(|(crate_type, _)| *crate_type == CrateType::Executable)
|
|
||||||
.expect("interpreting a non-executable crate");
|
.expect("interpreting a non-executable crate");
|
||||||
for cnum in dependency_format.1.iter().enumerate().filter_map(|(num, &linkage)| {
|
for cnum in dependency_format.iter().enumerate().filter_map(|(num, &linkage)| {
|
||||||
// We add 1 to the number because that's what rustc also does everywhere it
|
// We add 1 to the number because that's what rustc also does everywhere it
|
||||||
// calls `CrateNum::new`...
|
// calls `CrateNum::new`...
|
||||||
#[expect(clippy::arithmetic_side_effects)]
|
#[expect(clippy::arithmetic_side_effects)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue